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

fix: replace newline(\n) with br for text widgets. #7859

Closed
wants to merge 4 commits into from

Conversation

techbhavin
Copy link
Contributor

@techbhavin techbhavin commented Sep 27, 2021

Description

TextWidget text render imporve(`/n' issue fixed)

Fixes #7497

Type of change

  • Bugfix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Test coverage results 🧪

🟢 Total coverage has increased
// Code coverage diff between base branch:release and head branch: fix/text-wid-remove-newline 
Status File % Stmts % Branch % Funcs % Lines
🟢 total 54.82 (0) 36.83 (0.01) 33.89 (0) 55.41 (0)
🔴 app/client/src/widgets/TextWidget/component/index.tsx 100 (0) 77.27 (-1.06) 100 (0) 100 (0)

@somangshu
Copy link
Contributor

somangshu commented Sep 27, 2021

@techbhavin looks like the core problem is not the text widget, Can you confirm if this is reproducible on release env, I can seems to do that

also in the text widget \n seems to work fine

@somangshu somangshu requested review from marks0351 and removed request for somangshu September 27, 2021 14:08
@@ -76,6 +76,8 @@ class TextComponent extends React.Component<TextComponentProps> {
textAlign,
textColor,
} = this.props;
let procText = text || "";
Copy link
Contributor

@marks0351 marks0351 Sep 29, 2021

Choose a reason for hiding this comment

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

@techbhavin @somangshu what's the proposed fix here?
if we are going to allow break tags shouldn't we allow any html tag that might come from a rick text editor which includes bold, italics, etc?

Copy link
Contributor

Choose a reason for hiding this comment

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

@marks0351 The fix was actually for the new line character we see in the standup app, I thought the root cause would be the RTE or list widget, But was not able to reproduce this. I am not sure of the above change.

Copy link
Contributor

@somangshu somangshu Sep 29, 2021

Choose a reason for hiding this comment

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

An issue in the original package here says that

Currently it's impossible to match a string with line breaks because convertLineBreaks replaces all of them with <br/> tags which causes the matcher to get get a splitted string.

So how does the above resolve anything?

@techbhavin
Copy link
Contributor Author

@marks0351 @somangshu

Interweave package used underneath Text widget shows new line char "\n" as it is. So we need to replace "\n" with
before forwarding the text to the lib.

Interweave handles HTML / Markdown text perfectly.

@marks0351 marks0351 changed the title feat: replace newline with br fix: replace newline with br Sep 29, 2021
@marks0351 marks0351 changed the title fix: replace newline with br fix: replace newline(\n) with br for text widgets. Sep 29, 2021
@github-actions github-actions bot added the Bug Something isn't working label Sep 29, 2021
@YogeshJayaseelan
Copy link
Contributor

@techbhavin @RakshaKShetty Verified this PR now \n and quotes are not displayed.

@techbhavin techbhavin closed this Oct 5, 2021
@techbhavin techbhavin reopened this Oct 5, 2021
@techbhavin techbhavin marked this pull request as draft October 5, 2021 13:06
@somangshu somangshu removed their request for review October 6, 2021 10:36
@somangshu somangshu added the Widgets Product This label groups issues related to widgets label Oct 15, 2021
@mohanarpit
Copy link
Member

mohanarpit commented Oct 18, 2021

@techbhavin @somangshu Is this PR still required? If not, can we close this PR?

I'm asking because I've closed the linked Github issue as non-reproducible.

@somangshu
Copy link
Contributor

@mohanarpit we were just waiting to see if the issue crops up again, This has resolved for now, Closing this now

@somangshu somangshu closed this Oct 18, 2021
@mohanarpit mohanarpit deleted the fix/text-wid-remove-newline branch October 18, 2021 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Widgets Product This label groups issues related to widgets
Projects
None yet
6 participants