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

feat: alternate list marker type for nested lists #857

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

dcshzj
Copy link
Contributor

@dcshzj dcshzj commented Nov 5, 2024

Problem

Nested lists are currently using the same list marker type, which can be a little confusing and annoying to users.

Fixes ISOM-1662.

Solution

Breaking Changes

  • Yes - this PR contains breaking changes
  • No - this PR is backwards compatible

Features:

  • Make nested lists alternate between different list types:
    • For ordered lists: Use decimal, then lower-alpha, then lower-roman
    • For unordered lists: Use disc, then circle, then square

Bug Fixes:

  • Sometimes when the parent list item is "empty" (i.e. just spaces but not entirely empty), the child bullet gets collapsed together with it. We now force a line break if it is empty.

Notes:

  • This fix does not apply to the list inside the Tiptap editor itself, as I felt that fixing that would be a lot more complicated. If there is really a need/user confusion then we can explore fixes for this.

Before & After Screenshots

BEFORE:

image image

AFTER:

image image

@dcshzj dcshzj requested a review from a team as a code owner November 5, 2024 06:42
Copy link

linear bot commented Nov 5, 2024

Copy link

vercel bot commented Nov 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
isomer-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 5, 2024 6:42am

@datadog-opengovsg
Copy link

datadog-opengovsg bot commented Nov 5, 2024

Datadog Report

Branch report: feat/alternate-nested-lists
Commit report: 62a219a
Test service: isomer-studio

✅ 0 Failed, 167 Passed, 34 Skipped, 42.23s Total Time
🔻 Test Sessions change in coverage: 1 decreased (-0.01%)

🔻 Code Coverage Decreases vs Default Branch (1)

  • vitest run --coverage 1.18% (-0.01%) - Details

Copy link
Contributor

@seaerchin seaerchin left a comment

Choose a reason for hiding this comment

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

lgtm with 1 minor qn

@@ -21,6 +21,7 @@ const ListItem = ({ content, LinkComponent, site }: ListItemProps) => {
<OrderedList
key={index}
{...item}
level={!!level ? level + 1 : 1}
Copy link
Contributor

Choose a reason for hiding this comment

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

question: why is this level + 1 and 1 and not level and 0? does this have something to do with what tiptap sends us?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm nothing to do with Tiptap here. Cos level is optional so the burden of setting the level is not placed on users of a list component, so for the OrderedList and UnorderedList components, they will assume that they are at level 0 if it is not provided. This increment in level is because we are starting on the next nested list, so the first nested list will have a level of 1.

This has no schema change either, purely just a components thing to track which level the list is being called at.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah ok wait let me double check - this is an ordered list inside another ordered list so the level has to be minimally 1?

missed this on initial read

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops missed this, the first list is always at level 0 (zero-based indexing), then we increment the level every time we start a new nested list.

@dcshzj dcshzj merged commit 34344b6 into main Nov 6, 2024
19 of 21 checks passed
@dcshzj dcshzj deleted the feat/alternate-nested-lists branch November 6, 2024 02:00
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.

3 participants