Skip to content
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

[#12578] Fix @ issue by using innerHTML tag #12586

Conversation

RohithSurya
Copy link
Contributor

Fixes #12578

Outline of Solution

I have identified that the backend database stores special characters as HTML-encoded entities, which is sent back to the UI.

My solution is to fix the issue in the UI by decoding the HTML characters and showing them in the UI.
I found two ways to do this. Both have advantages and disadvantages, but both approaches work flawlessly as far as I have tested them.

The first approach was to use the innerHtml tag, which automatically decodes text, but for this, ngModel should be removed since ngModelChange works with ngModel; it also has to be removed and replaced with input event so that event binding to the variable works.

The second approach its to use approach mentioned here https://www.npmjs.com/package/decode-html-entities.
The second approach is to create another textarea that does the decoding and gets its value to be shown in the UI.

The code for the above approach is simple, but it requires the creation of another texture
transform(value: any, args: any[]): any {
if (!value) return;
let txt = document.createElement("textarea");
txt.innerHTML = value;
return txt.value;
}

I went with the first approach rather than creating a new textarea box.

@github-actions
Copy link

Hi @RohithSurya, thank you for your interest in contributing to TEAMMATES!
However, your PR does not appear to follow our contribution guidelines:

  • Title must start with the issue number the PR is fixing in square brackets, e.g. [#<issue-number>]

Please address the above before we proceed to review your PR.

@RohithSurya RohithSurya changed the title [12578] Fix @ issue by using innerHTML tag [#12578] Fix @ issue by using innerHTML tag Sep 12, 2023
@cedricongjh cedricongjh self-requested a review September 12, 2023 14:17
@cedricongjh cedricongjh added the s.ToReview The PR is waiting for review(s) label Sep 12, 2023
Copy link
Contributor

@cedricongjh cedricongjh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the exploration for the fix!

Before we proceed to review the PR, do update the failing snapshot tests. To update to update the snapshot tests, run npm run test and press a to run all test cases. After that, check through the snapshots to make sure the changes are as expected, then press u to update them.

@RohithSurya
Copy link
Contributor Author

I forgot to check the tests.. I will fix the snapshots asap.

@nusoss-bot
Copy link

Folks, This PR seems to be stalling (no activities for the past 7 days). 🐌 😢
Hope someone can get it to move forward again soon...

@jasonqiu212 jasonqiu212 added s.Ongoing The PR is being worked on by the author(s) and removed s.ToReview The PR is waiting for review(s) labels Sep 22, 2023
@weiquu
Copy link
Contributor

weiquu commented Sep 27, 2023

Closing due to inactivity.

@weiquu weiquu closed this Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s.Ongoing The PR is being worked on by the author(s)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@ sign is shown as &#64; when viewing essay question submission page
5 participants