Skip to content

Conversation

@iulia-b
Copy link
Contributor

@iulia-b iulia-b commented Nov 29, 2023

Hubbers reported that the new Issues UI was sometimes not responding to checking boxes. After investigating this with @japf we realized that it was due to the fact that those templates were written on a Windows machine and contained \r\n as a newline character, which was not parsed correctly inside MDViewer

Changelog

New

Changed

  • updated newLine splitter from \n to /\r?\n/ throughout markdown handling related files

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan

Testing & Reviewing

Merge checklist

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@iulia-b iulia-b requested review from a team and mperrotti November 29, 2023 14:15
@changeset-bot
Copy link

changeset-bot bot commented Nov 29, 2023

🦋 Changeset detected

Latest commit: 9d07bf4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR


const singleWordTriggerTerminators = new Set([' ', '\n'])
const multiWordTriggerTerminators = new Set(['.', '\n'])
const singleWordTriggerTerminators = new Set([' ', '\n', '\r\n'])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure these are needed but it looks safe to me + no tests are failing

Copy link
Contributor

Choose a reason for hiding this comment

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

It technically shouldn't be necessary because I think this issue only shows up with templates when they are written offline in external editors. That said, it doesn't hurt to add it.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 29, 2023

size-limit report 📦

Path Size
dist/browser.esm.js 104.34 KB (0%)
dist/browser.umd.js 104.85 KB (0%)

`${item.leadingWhitespace}${typeof item.delimeter === 'number' ? `${item.delimeter}.` : item.delimeter}${
item.middleWhitespace
}${item.taskBox || ''} ${item.text}`
typeof item.delimeter === 'number'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've split this on 2 lines for readability + different handling : in the case of numbered list, i chose to ignore the "middle" spacing and format the MD correctly - because it is displayed in the correct way, ignoring the extra spaces

Copy link
Contributor

@iansan5653 iansan5653 Nov 29, 2023

Choose a reason for hiding this comment

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

Not sure I totally understand this. Aren't those extra spaces always rendered as a single space? I figure we'd want to keep the user's raw markdown as close as possible to what they actually wrote when we modify it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this changes the number of spaces for lists that are numbered. I intentionally did this - not sure it's correct but it was a subjective thinking that lists with numbers , given they're also displayed with single space, might as well be "fixed"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the intentional "fixes" and added tests here and here

@github-actions github-actions bot temporarily deployed to storybook-preview-3987 November 29, 2023 14:19 Inactive
@@ -0,0 +1,88 @@
import {parseListItem, listItemToString, ListItem} from '../../drafts/MarkdownEditor/_useListEditing'

describe('parseListItem', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

👏

item.middleWhitespace
}${item.taskBox || ''} ${item.text}`
typeof item.delimeter === 'number'
? `${item.leadingWhitespace}${`${item.delimeter}.`} ${item.text}`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the delimiter is the dot, so this would add an extra dot:

Suggested change
? `${item.leadingWhitespace}${`${item.delimeter}.`} ${item.text}`
? `${item.leadingWhitespace}${item.delimeter} ${item.text}`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The delimiter is the number. The dot was there before as well. There is a test covering this

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yeah, definitely see that now. That's what I get for reviewing from mobile 😄

@github-actions github-actions bot temporarily deployed to storybook-preview-3987 December 5, 2023 09:39 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3987 December 5, 2023 10:59 Inactive
Copy link
Contributor

@iansan5653 iansan5653 left a comment

Choose a reason for hiding this comment

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

🚢

item.middleWhitespace
}${item.taskBox || ''} ${item.text}`
typeof item.delimeter === 'number'
? `${item.leadingWhitespace}${`${item.delimeter}.`}${item.middleWhitespace}${item.text}`
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] extra string nesting is unnecessary here

Suggested change
? `${item.leadingWhitespace}${`${item.delimeter}.`}${item.middleWhitespace}${item.text}`
? `${item.leadingWhitespace}${item.delimeter}.${item.middleWhitespace}${item.text}`

@iulia-b iulia-b enabled auto-merge December 6, 2023 09:39
@github-actions github-actions bot temporarily deployed to storybook-preview-3987 December 6, 2023 09:45 Inactive
Copy link
Member

@siddharthkp siddharthkp left a comment

Choose a reason for hiding this comment

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

The changes are scoped to drafts/MarkdownEditor and drafts/MarkdownEditor, I trust @iansan5653's review on them :)

@iulia-b iulia-b added this pull request to the merge queue Dec 6, 2023
@siddharthkp siddharthkp removed this pull request from the merge queue due to a manual request Dec 6, 2023
@siddharthkp siddharthkp added this pull request to the merge queue Dec 6, 2023
Merged via the queue into main with commit 4321d59 Dec 6, 2023
@siddharthkp siddharthkp deleted the mdViewer/end-of-line-separators branch December 6, 2023 14:40
@primer primer bot mentioned this pull request Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants