-
Notifications
You must be signed in to change notification settings - Fork 202
feat(combobox): adding new s2 migration #3683
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
base: spectrum-two
Are you sure you want to change the base?
feat(combobox): adding new s2 migration #3683
Conversation
🦋 Changeset detectedLatest commit: 3daface The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
markdownlint-fix
[markdownlint-fix] reported by reviewdog 🐶
spectrum-css/components/checkbox/dist/metadata.json
Lines 195 to 197 in a986db0
"--spectrum-gray-50", | |
"--spectrum-gray-700", | |
"--spectrum-gray-800", |
[markdownlint-fix] reported by reviewdog 🐶
"--spectrum-negative-color-1100", |
[markdownlint-fix] reported by reviewdog 🐶
spectrum-css/components/checkbox/dist/metadata.json
Lines 202 to 205 in a986db0
"--spectrum-neutral-background-color-selected-default", | |
"--spectrum-neutral-background-color-selected-down", | |
"--spectrum-neutral-background-color-selected-hover", | |
"--spectrum-neutral-background-color-selected-key-focus", |
[markdownlint-fix] reported by reviewdog 🐶
"--spectrum-text-to-control-100", |
[markdownlint-fix] reported by reviewdog 🐶
"--highcontrast-checkbox-color-hover", |
[markdownlint-fix] reported by reviewdog 🐶
"--highcontrast-checkbox-highlight-color-focus", |
File metricsSummaryTotal size: 1.42 MB*
File change detailscombobox
helptext
* An ASCII character in UTF-8 is 8 bits or 1 byte. |
🚀 Deployed on https://pr-3683--spectrum-css.netlify.app |
a986db0
to
ff02395
Compare
7e8269c
to
4ce8d19
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice work addressing the feedback from before! I have a few (15? 😬 ) other comments. I definitely see that I've pointed out several things that aren't new in this migration but existing issues from before that hopefully we can improve going forward.
autocomplete: { | ||
table: { | ||
disable: true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to access autocomplete styles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even with &:autofill
selector added the styles won't change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, yeah, I see now that the autocomplete
attribute on combobox and textfield doesn't work as I would have expected it to. We still need to be able to apply those autocomplete styles though.
Looking at Web Components and React's implementations as well as MDN, it seems like maybe we'd want aria-autocomplete="list"
instead? That seems to be the one that's turned on when autocomplete is working.
I don't see any added styles in index.css
related to the design spec'd colors for autocomplete/autofill, did you add any? We should still have some way to make the autocomplete styles visible even if we don't implement any autocomplete functionality here so that SWC would be able to apply those autocomplete styles eventually.
My best guess would be to apply a selector like
.spectrum-Combobox-input[aria-autocomplete="list"] {
/* Your autocomplete-specific styles here */
}
And then wire up an autocomplete Storybook control that would apply this attribute to the input, and then therefore apply the styles? Would that work?
components/combobox/index.css
Outdated
} | ||
} | ||
|
||
.spectrum-Combobox { | ||
position: relative; | ||
display: inline-flex; | ||
flex-flow: row nowrap; | ||
display: inline-grid; | ||
|
||
inline-size: var(--mod-combobox-inline-size, var(--spectrum-combobox-inline-size)); | ||
min-inline-size: var(--mod-combobox-min-inline-size, var(--spectrum-combobox-min-inline-size)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's another thing about combobox that I'm wondering about that I sort of touched on in another comment: Should the min-inline-size
be set on .spectrum-Combobox
or on .spectrum-Combobox-input
? When we have a side label the input tends to shrink a lot, in this case it's about 78.5px. Since the minimum width token is a multiplier (2.5 * the height, which is 32px), it looks like for this particular size the combobox should be a minimum of 80px. Which it is, if we're talking about the field label + input width, but the input is smaller. I know this is how it was before, but was that what was intended?


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rise-erpelding Looking at the component a little closer in Figma, it looks like side label and the input are half of the combobox in width.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aramos-adobe I placed a min inline size of 50% for both label and the content (parent containing the inputs). I have seen any weird movements yet in the button. I did place a position: relative
on the .spectrum-Combobox-content
to keep the button at the end of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the 50% min sizing helps (textfield also has its own similar min sizing calc on the input, which helps here too) and that does match the way they're doing it in the Desktop Figma side label variants I see there, but the way I understood that combo-box-minimum-width-multiplier
token to work is that it applies to the textfield input or any element that's the same width as the input, such as .spectrum-Combobox-content
. Instead you have the combo-box-minimum-width-multiplier
token on --spectrum-combobox-min-inline-size
and then it's applied to .spectrum-Combobox
, which includes the width of the input but also the width of the label.
I only see one instance where that's violated: XL(mobile), where the component height is 60px, so the min-width should be 60 * 2.5 = 150px but the component is just a few px shy of meeting that min-width.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really close! I had few last comments that don't seem directly related to these S2 migration changes but I thought I'd point out just in case.
} | ||
|
||
/* TEXT INPUT */ | ||
.spectrum-Combobox-input { | ||
padding-block-start: calc(var(--mod-combobox-spacing-block-start-edge-to-text, var(--spectrum-combobox-spacing-block-start-edge-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); | ||
padding-block-end: calc(var(--mod-combobox-spacing-block-end-edge-to-text, var(--spectrum-combobox-spacing-block-end-edge-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); | ||
background-color: var(--highcontrast-combobox-background-color-default, var(--mod-combobox-textfield-background-color, var(--spectrum-combobox-background-color-default))); | ||
padding-inline-start: calc(var(--mod-combobox-spacing-inline-start-edge-to-text, var(--spectrum-combobox-spacing-inline-start-edge-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@saashapina @rise-erpelding, I deconstructed the component in Figma and even if you remove the border it's still using the edge-to-text token regardless. The border/stroke line position is set to center of the combobox so it's going all the way to the edge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To recap: @aramos-adobe and I talked this through and decided that the token spec is wrong and that the padding should be including the border (so the spacing is from the edge including the border), and therefore it does still need the calc to add only the spacing we need that isn't taken up by the border width.
} | ||
|
||
const popoverHeight = size === "s" ? 106 : size === "l" ? 170 : size === "xl" ? 229 : 142; // default value is "m" | ||
const adjustedPopoverHeight = showFieldLabel ? popoverHeight : popoverHeight + 32; // Subtract label height when no label | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@saashapina It's like this on the Picker as well and any other component using the Popover. Maybe this could a bug worth reporting in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few more comments here.
I also had one that wasn't part of the PR review that might easily get lost, we need to address the divider at some point even if we remove it from the menu here to avoid horizontal scrolling, I don't think the divider width shouldn't be determining the width of the menu.
Also, this line-height token as it's defined will be problematic in Thai due to diacritic cutoff. It may be worthwhile to ignore that token and set line-height to the component height, like we did in #3256 or #2123, we've also previously needed to modify styles in picker to address this issue like in #2914--not sure which approach is best (maybe just leave it to inherit textfield's styles?), but putting all of our previous PRs on this topic out there for context.
} | ||
|
||
/* TEXT INPUT */ | ||
.spectrum-Combobox-input { | ||
padding-block-start: calc(var(--mod-combobox-spacing-block-start-edge-to-text, var(--spectrum-combobox-spacing-block-start-edge-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); | ||
padding-block-end: calc(var(--mod-combobox-spacing-block-end-edge-to-text, var(--spectrum-combobox-spacing-block-end-edge-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); | ||
background-color: var(--highcontrast-combobox-background-color-default, var(--mod-combobox-textfield-background-color, var(--spectrum-combobox-background-color-default))); | ||
padding-inline-start: calc(var(--mod-combobox-spacing-inline-start-edge-to-text, var(--spectrum-combobox-spacing-inline-start-edge-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
components/combobox/index.css
Outdated
--mod-textfield-spacing-block-start: calc(var(--mod-combobox-spacing-block-start-edge-to-text, var(--spectrum-combobox-spacing-block-start-edge-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); | ||
--mod-textfield-spacing-block-end: calc(var(--mod-combobox-spacing-block-end-edge-to-text, var(--spectrum-combobox-spacing-block-end-edge-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
components/combobox/index.css
Outdated
} | ||
} | ||
|
||
.spectrum-Combobox { | ||
position: relative; | ||
display: inline-flex; | ||
flex-flow: row nowrap; | ||
display: inline-grid; | ||
|
||
inline-size: var(--mod-combobox-inline-size, var(--spectrum-combobox-inline-size)); | ||
min-inline-size: var(--mod-combobox-min-inline-size, var(--spectrum-combobox-min-inline-size)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the 50% min sizing helps (textfield also has its own similar min sizing calc on the input, which helps here too) and that does match the way they're doing it in the Desktop Figma side label variants I see there, but the way I understood that combo-box-minimum-width-multiplier
token to work is that it applies to the textfield input or any element that's the same width as the input, such as .spectrum-Combobox-content
. Instead you have the combo-box-minimum-width-multiplier
token on --spectrum-combobox-min-inline-size
and then it's applied to .spectrum-Combobox
, which includes the width of the input but also the width of the label.
I only see one instance where that's violated: XL(mobile), where the component height is 60px, so the min-width should be 60 * 2.5 = 150px but the component is just a few px shy of meeting that min-width.
autocomplete: { | ||
table: { | ||
disable: true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, yeah, I see now that the autocomplete
attribute on combobox and textfield doesn't work as I would have expected it to. We still need to be able to apply those autocomplete styles though.
Looking at Web Components and React's implementations as well as MDN, it seems like maybe we'd want aria-autocomplete="list"
instead? That seems to be the one that's turned on when autocomplete is working.
I don't see any added styles in index.css
related to the design spec'd colors for autocomplete/autofill, did you add any? We should still have some way to make the autocomplete styles visible even if we don't implement any autocomplete functionality here so that SWC would be able to apply those autocomplete styles eventually.
My best guess would be to apply a selector like
.spectrum-Combobox-input[aria-autocomplete="list"] {
/* Your autocomplete-specific styles here */
}
And then wire up an autocomplete Storybook control that would apply this attribute to the input, and then therefore apply the styles? Would that work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great and I think it's mostly there! Just a couple of smaller things for this round!
} | ||
|
||
/* TEXT INPUT */ | ||
.spectrum-Combobox-input { | ||
padding-block-start: calc(var(--mod-combobox-spacing-block-start-edge-to-text, var(--spectrum-combobox-spacing-block-start-edge-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); | ||
padding-block-end: calc(var(--mod-combobox-spacing-block-end-edge-to-text, var(--spectrum-combobox-spacing-block-end-edge-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); | ||
background-color: var(--highcontrast-combobox-background-color-default, var(--mod-combobox-textfield-background-color, var(--spectrum-combobox-background-color-default))); | ||
padding-inline-start: calc(var(--mod-combobox-spacing-inline-start-edge-to-text, var(--spectrum-combobox-spacing-inline-start-edge-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To recap: @aramos-adobe and I talked this through and decided that the token spec is wrong and that the padding should be including the border (so the spacing is from the edge including the border), and therefore it does still need the calc to add only the spacing we need that isn't taken up by the border width.
components/combobox/index.css
Outdated
box-shadow: 0 0 0 30px var(--spectrum-combobox-background-color-autofill) inset !important; | ||
transition: background-color 5000s ease-in-out 0s; | ||
-webkit-text-fill-color: var(--spectrum-neutral-content-color-default) !important; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I'm so pumped for these styles! I also totally missed that it gets a color background (but I see that now in the Desktop spec), that was left out of the token spec, wasn't it?
A couple of small thoughts I have on this:
- The border color should be set here,
gray-800
for autocomplete. - Invalid border color also has tokens for the autocomplete state, but... it's the same as default so I don't think you need to add anything for that.
- Since we're setting
box-shadow
and notbackground-color
for the background color, I don't know that the transition is doing much here. It's also a really long transition! - Using
box-shadow
is a great hack here! Looking at the autocomplete state in the Desktop spec, it looks like only the highlighted text (would that be::selection
? honestly not sure) is meant to be that blue color? What if we set thebox-shadow
color togray-25
(to override the user agent bg color) and then add a selector for::selection
, something that's maybe like this? (There are probably better custom props to use but just to give an example)
&:-webkit-autofill,
&:-webkit-autofill:hover,
&:-webkit-autofill:focus,
&:-webkit-autofill:active,
&:-internal-autofill-selected,
&.spectrum-Combobox-autocomplete {
border-color: var(--spectrum-gray-800);
box-shadow: 0 0 0 30px var(--spectrum-gray-25) inset !important;
transition: background-color 5000s ease-in-out 0s; /* not sure about keeping this I'm just leaving it alone for now */
-webkit-text-fill-color: var(--spectrum-neutral-content-color-default) !important;
&::selection {
background-color: var(--spectrum-combobox-background-color-autofill);
}
}
It's still a little problematic because the design shows something like this:
And that code would show something like this but only if you highlight it, which I assume you could do programmatically:
If our line-height is set to the component height it doesn't fully match, but I think we would want that line-height set to the component height so I'm not sure what the right answer is there.
I think either way this is going to need some adjusting when the component or the autocomplete feature is actually being built out, but it's a start... what are your thoughts?
Whatever you decide, just one more note to double-check it in WHCM, currently it looks like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving a few thoughts about the autofill, I don't think it quite works as we have it now, but I think that we can leave some of it as follow-up work, interested to know what you think as well!
components/combobox/index.css
Outdated
&:-webkit-autofill, | ||
&:-webkit-autofill:hover, | ||
&:-webkit-autofill:focus, | ||
&:-webkit-autofill:active, | ||
&:-internal-autofill-selected, | ||
&.spectrum-Combobox-autocomplete { | ||
border-color: var(--spectrum-gray-800); | ||
box-shadow: 0 0 0 30px var(--spectrum-combobox-background-color-default) inset !important; | ||
transition: background-color 5000s ease-in-out 0s; /* not sure about keeping this I'm just leaving it alone for now */ | ||
-webkit-text-fill-color: var(--spectrum-neutral-content-color-default) !important; | ||
line-height: var(--spectrum-combobox-line-height); | ||
|
||
&::selection { | ||
background-color: var(--spectrum-combobox-background-color-autofill); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, this autocomplete is starting to be a little problematic... here are some thoughts/questions I have now:
- Should we use a custom property for the border instead of
--spectrum-gray-800
? We have--spectrum-combobox-border-color-default
,--spectrum-combobox-border-color-hover
, etc. that we already use, for instance. - I think 5000s is a bit long for an animation-duration, although it is true that we have no guidance for this (I'm also not seeing this doing much of anything either way?).
- We also have no guidance for WHCM, but I'm guessing it might be jarring to enforce the white background color that I'm seeing now when all the others are dark.
- Changing the line-height for autofill only does make the highlight work as intended, but we'll still get cutoff for Thai in that case.
I'd initially only seen the autocomplete styles for border and text color, and hadn't seen the other spec where we're doing the highlight things... I'm kind of inclined to say that since trying to implement the highlight is causing a lot of issues + we also don't have great guidance for it now + at least in my opinion, we'd want to style this in a way that we know will be compatible with SWC, I'd be ok with only styling what's on the token spec (border and text color) and leaving this background-color/highlight portion alone for now, what are your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! We're leaving autocomplete now in a good place where it can be picked up later if it's implemented in a way that's different from S1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for answering those questions Aziz! I think this looks g2g 👍
Combobox S2 Migration
The new combo box is coming in with more pronounced corner radius, thicker outline, and the use of the infield button nested inside. The quiet styling has also been deprecated.
New tokens
--spectrum-combobox-font-weight
--spectrum-combobox-line-height-cjk
--spectrum-combobox-spacing-alert-icon-to-text
--spectrum-combobox-spacing-to-help-text
New mods
--mod-combobox-line-height-cjk
--mod-combobox-popover-animation-distance
--mod-combobox-spacing-alert-icon-to-text
--mod-combobox-spacing-to-help-text
--mod-combobox-textfield-background-color
How and where has this been tested?
Please tag yourself on the tests you've marked complete to confirm the tests have been run by someone other than the author.
Validation steps
Regression testing
Validate:
Screenshots
S1
S2
To-do list