Skip to content

Conversation

aveline
Copy link
Contributor

@aveline aveline commented Dec 20, 2022

WHY are these changes introduced?

Fixes #7952

WHAT is this pull request doing?

Updates OptionList to use new layout primitives.

One small visual change with this update due to replacing margin with padding is a slight increase (4px) in spacing when there are multiple sections in an OptionList. I don't think the added complexity to keep this the same as current doesn't seem worth it, but happy to hear other thoughts.

Update: Added a Bleed to resolve the spacing change. Feels hacky but prevents the visual change.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 20, 2022

size-limit report 📦

Path Size
polaris-react-cjs 211.39 KB (+0.03% 🔺)
polaris-react-esm 136.55 KB (+0.03% 🔺)
polaris-react-esnext 192.2 KB (-0.02% 🔽)
polaris-react-css 42 KB (-0.09% 🔽)

@aveline aveline requested review from alex-page, laurkim and kyledurand and removed request for alex-page December 20, 2022 18:02
@aveline aveline self-assigned this Dec 20, 2022
@aveline aveline marked this pull request as ready for review December 20, 2022 18:03
Copy link
Contributor

@laurkim laurkim left a comment

Choose a reason for hiding this comment

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

Tophatted all the stories for OptionList at the breakpoints locally and all except the one with sections look visually the same, but I know you mentioned the extra spacing in the description 👍

It's probably worth confirming with @sarahill or @nayeobkim that the extra 4px is okay before merging this to the batch 3 branch.

Copy link
Member

@kyledurand kyledurand left a comment

Choose a reason for hiding this comment

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

Code looks good but I think I'd prefer if we found a way to keep the same spacing. Plus 1 on waiting for UX before 🚢 ing

role={role}
>
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
{/* @ts-ignore OptionList allows string as role but Box doesn't. @TODO: remove string from OptionList in v11 */}
Copy link
Member

Choose a reason for hiding this comment

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

👍 Let's just make sure this is added to the v11 road map / issue / PR, whatever we have going for that

Another thing I think you could do is cast role as BoxProps['role'] or maybe as unknown as BoxProps['role'] and that way you wouldn't need 4 lines of comments. I'm fine with leaving it as is, maybe uglier is better for visibility

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a branch for v11 #7597 so I'll go ahead and open a pr against it.

<ul className={styles.OptionList} role={role}>
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore OptionList allows string as role but Box doesn't. @TODO: remove string from OptionList in v11
<Box as="ul" role={role} padding="2">
Copy link
Member

Choose a reason for hiding this comment

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

It seems like this is where the added space is coming from. Can we use isFirstOption here to change the value like you did above?

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 added spacing only happens on sections where there's no title, that's the combination where there were overlapping margins.

I added a Bleed to handle that and resolve the change in spacing. It feels hacky but at least it prevents the visual regression.

<Box
as="ul"
id={`${id}-${sectionIndex}`}
role={role as BoxProps['role']}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice 💯

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 think the uglier version with all the comments is better for visibility. But we can ship either one.

Copy link
Contributor

Choose a reason for hiding this comment

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

I do agree the one with all the comments was better for visibility to know to remove it but I'm okay with either version!

Copy link
Member

@kyledurand kyledurand left a comment

Choose a reason for hiding this comment

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

🎉

@aveline aveline merged commit 8bf8936 into layout-rebuild-batch-3 Jan 3, 2023
@aveline aveline deleted the layout-option-list branch January 3, 2023 17:12
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