-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting the highlighted code to empty string will not reflect the value change #119
Comments
Please use stackblitz for reproduction https://stackblitz.com/edit/ngx-highlightjs If you look at the source code ngx-highlightjs/projects/ngx-highlightjs/src/lib/highlight.ts Lines 52 to 60 in 76287be
As long as you don't pass null value, it should set the text. can you confirm that you input is not passing a null value |
@MurhafSousli here you go: https://stackblitz.com/edit/ngx-highlightjs-sftnnx try to delete the text from the input and you'll see the bug I think removing this line |
@MurhafSousli any news on this? were you able to reproduce the issue? |
Here https://stackblitz.com/edit/ngx-highlightjs-yp5rvq?file=src/app/home/home.component.ts It turns out that if you want bind code to an input or textarea, you need to turn of the line numbers feature |
@MurhafSousli why closing this issue? that link of yours still has the same bug: |
Confirmed. |
The thing the value you are passing is not EMPTY, it is null value https://stackblitz.com/edit/ngx-highlightjs-yp5rvq?file=src%2Fapp%2Fhome%2Fhome.component.ts When you pass null, replace with space |
@MurhafSousli that way you are hacking it to be a space The bug is that |
Thats right, maybe we can check if the |
@MurhafSousli yes, or even better just set to |
Fixed in v4.1.1, working stackblitz https://stackblitz.com/edit/ngx-highlightjs-bz2bqz |
I think this fix was undone by commit d60dc10 (for issue #142), such as in 4.1.3 (for Angular 11). I realize that you may want to have |
@estanglerbm can you provide a stackblitz to demonstrate the use case? |
https://stackblitz.com/edit/angular-ivy-ypchsm?file=src/app/app.component.html If you click the yellow box for JSON or SQL, and then click on Blank, then the area under "Issue #119" doesn't get updated. If you click any yellow box except SQL, then click SQL, then any other yellow box, then the area under "Issue Other" doesn't get updated ever again (except perhaps for SQL). The "Issue #119" area is about just highlighting code, and handling a blank value. This affects 4.1.3 with Angular 11, too. |
I am experiencing this issue, but it's easily solvable: <code [highlight]="value || ' '"></code> That being said, I think the content should be updated even if it's |
I know (my stackblitz illustrated the space workaround, too), but there may be cases where a space character is not desired. But the real issue here, as I previously mentioned, is that there are two use cases: one where you want nothing to happen, and one where you want to clear the area. There should be a mechanism to do both things (and a highlight="" would probably do one of them, and another mechanism does the other, or maybe solve the situation differently). Otherwise, you're just going to continue to have future commits conflicting on this, because some people expect highlight="" to do nothing, and others expect highlight="" to clear the area. |
@estanglerbm I would recommend listing all the use cases and their expected behaviour as bullet points to easily follow on them. I find it confusing to read the use cases and how it should behave from the comment or from the stackblitz. |
@MurhafSousli I'd recommend a test case which will prevent this issue from being introduced again by mistake |
Ok, it is fixed in 6.1.1 and I added test cases for that. Now the expected behavior is the following:
|
@MurhafSousli Fantastic. (I can't test it for a while, but the behavior sounds good.) Thanks. |
Bug Report or Feature Request (mark with an
x
)OS and Version?
Ubuntu 18.04
Versions
Description
I'm having a hard time updating from version 3.x to version 4.x as whenever in my app I change the code from a non-empty string to an empty string (
''
), the change will not be reflectedRepro steps
I've created a minimal application that reproduces the issue:
npm i && ng serve
I tested on both versions
v4.0.2
andv4.1.0-beta
, the bug is the same.It worked correctly on version
v3.0.3
Desired functionality
Should correctly update the view displaying an empty string
Mention any other details that might be useful
This bug appeared in 4.x, it worked fine in version 3.x
The text was updated successfully, but these errors were encountered: