-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[HOLD for payment 2023-03-01] [$1000] Editing header bold text in chat increases vertical gap above the text #14668
Comments
@shawnborton can you confirm this is indeed a bug, and I'll get it moved over? |
Shawn is OOO, but back this week! |
Hm yeah, this seems like a bug! It's a bit strange that there was even a blank line inserted above the #/headline in the first place. |
Nice, thanks Shawn! |
Replicated |
Job added to Upwork: https://www.upwork.com/jobs/~011432c27e94a6da98 |
Current assignee @dylanexpensify is eligible for the External assigner, not assigning anyone new. |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @eVoloshchak ( |
Triggered auto assignment to @danieldoglas ( |
This comment was marked as outdated.
This comment was marked as outdated.
Proposal Please re-state the problem that we are trying to solve in this issue.If we edit a sent header bold text, What is the root cause of that problem?When translating html <h1>heading</h1> will be translated into markdown string
If we change the markdown text to
and save it, then markdown text
will be translated to html <br /><h1>heading test<h1> by applying markdown-to-html rules The leading line break will be translated to the extra To have a closer look at the root cause, let's try another example. Send a heading message
In the editing mode, change the markdown string
to (remove the leading and trailing line break)
Save it and the leading line break is still there. This is because when we save a changed message, we don't simply call
instead of
See https://github.com/Expensify/App/blob/main/src/libs/actions/Report.js#L829-L832 So the root cause is the invalid regex rule to translate html What changes do you think we should make in order to solve the problem?To fix this issue, we should improve the regex rule to translate to the following regex: /([\s\S]*?)\s*<(h1)(?:"[^"]*"|'[^']*'|[^'">])*>(.*?)<\/\2>(?![^<]*(<\/pre>|<\/code>))\s*([\s\S]*)/gi,
replacement: (match, g1, g2, g3, g4, g5) => `${g1}${g1 && '\n'}# ${g3}${g5 && '\n'}${g5}`, So the html <h1>heading</h1> will be translated to markdown text
and the edited markdown text
will be translated into html <h1>heading test</h1> What alternative solutions did you explore? (Optional)Call trim method for markdown text |
I reviewed @eh2077 and @tienifr's proposals. Great. flex-direction: row;align-items: center;Applying style eliminates the need to remove two duplicate \n's before converting the markdown to HTML. |
Hey @hackykitty, you might want to read our contributing guidelines to help you better understand the flow. (After that you might want to join expensify's slack channel!) |
ProposalPlease re-state the problem that we are trying to solve in this issue.Vertical gap above the text is increased after editing a What is the root cause of that problem?In Why non-new-line? because if before the heading there's already a new line, the What changes do you think we should make in order to solve the problem?In here, we should use a regex that satisfies the requirement diff --git a/lib/ExpensiMark.js b/lib/ExpensiMark.js
index bac4b81..5622980 100644
--- a/lib/ExpensiMark.js
+++ b/lib/ExpensiMark.js
@@ -229,8 +229,8 @@ export default class ExpensiMark {
},
{
name: 'heading1',
- regex: /\s*<(h1)(?:"[^"]*"|'[^']*'|[^'">])*>(.*?)<\/\1>(?![^<]*(<\/pre>|<\/code>))\s*/gi,
- replacement: '\n# $2\n',
+ regex: /([^\r\n]*?)\s*<(h1)(?:"[^"]*"|'[^']*'|[^'">])*>(.*?)<\/\2>(?![^<]*(<\/pre>|<\/code>))\s*([^\r\n]*)/gi,
+ replacement: (match, g1, g2, g3, g4, g5) => `${g1}${g1 && '\n'}# ${g3}${g5 && '\n'}${g5}`,
},
{
name: 'listItem',
After this fix, another issue will occur. Let's consider this HTML In order to fix this we need to introduce another property into the
Of course the regex above will need to have the global flag We'll need to evaluate other block elements (like blockquote, pre) to make sure it's not having this bug. If we're doing to those elements the same thing we do to There's another bug relating to the What alternative solutions did you explore? (Optional) |
ProposalTo fix the following test case mentioned by @tienifr in his latest proposal #14668 (comment) <h1>heading 1</h1><h1>heading 2</h1> I'd like to update the solution section of my previous proposal What changes do you think we should make in order to solve the problem?I'd like to propose a new solution to improve the regex rule which translates html with replacement: '[block]# $2[block]', By replacing
with
we can reuse this function
|
@eVoloshchak what's your saying on these proposals? |
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
Regression Test Proposal
Do we agree 👍 or 👎 |
📣 @eh2077! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Format:
|
✅ Contributor details stored successfully. Thank you for contributing to Expensify! |
@eVoloshchak can you fill this #14668 (comment)? Thanks! |
I like those steps, @eh2077 with some slight tweaking on the verbiage. @danieldoglas I'm curious on your thoughts if we should create a test for this? Or if you think this would get caught without a test? I'm tempted to say the latter. |
@dylanexpensify I think we should include this as part of the tests related to the markdown edits. |
Sure, doing it today |
|
Whipping up RT and payments today |
Hmm @danieldoglas, under the existing markdown test |
@dylanexpensify I think we're being very generalistic in |
Bump @danieldoglas! 🙇♂️ |
Hi @dylanexpensify , is this comment from @danieldoglas you're waiting for? |
Wow, yes @eh2077 haha, I didn't refresh issue before posting 🤦 |
RT linked above! Working on payments now! |
@eh2077 sent offer! |
@dylanexpensify Thanks and accepted the offer! |
@eh2077 payment sent! |
@dylanexpensify Thanks and accepted the offer! |
@dhanashree-sawant please apply when you can! |
Hi @dylanexpensify, I have accepted your invite |
oh woops! JEEZ I really have to start reloading the page before replying 🤦 |
Offer sent @dhanashree-sawant ! |
alrightyyyy we're all settled up!! Thanks everyone!! |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Action Performed:
Expected Result:
Vertical gap above the text should not change after edit
Actual Result:
Vertical gap above the text is increased after editing
Workaround:
unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: 1.2.61-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos:
vertical.gap.above.header.text.mp4
Recording.1404.mp4
Expensify/Expensify Issue URL:
Issue reported by: @dhanashree-sawant
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1675067869948869
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: