Skip to content

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

Open
wants to merge 29 commits into
base: spectrum-two
Choose a base branch
from

Conversation

aramos-adobe
Copy link
Contributor

@aramos-adobe aramos-adobe commented Apr 23, 2025

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

  • Combobox matches the token spec
  • Layout
  • Icons
  • Embedded components
  • Colors
  • Typography

Regression testing

Validate:

  1. The documentation pages for at least two other components are still loading, including:
  • The pages render correctly, are accessible, and are responsive.
  1. If components have been modified, VRTs have been run on this branch:
  • VRTs have been run and looked at.
  • Any VRT changes have been accepted (by reviewer and/or PR author), or there are no changes.

Screenshots

S1

Screenshot 2025-05-06 at 1 27 23 PM

S2

Screenshot 2025-05-06 at 1 26 55 PM

To-do list

  • I have read the contribution guidelines.
  • I have updated relevant storybook stories and templates.
  • I have tested these changes in Windows High Contrast mode.
  • If my change impacts other components, I have tested to make sure they don't break.
  • If my change impacts documentation, I have updated the documentation accordingly.
  • ✨ This pull request is ready to merge. ✨

Copy link

changeset-bot bot commented Apr 23, 2025

🦋 Changeset detected

Latest commit: f93eedb

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

This PR includes changesets to release 1 package
Name Type
@spectrum-css/combobox Major

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

@aramos-adobe aramos-adobe self-assigned this Apr 23, 2025
@aramos-adobe aramos-adobe marked this pull request as draft April 23, 2025 16:30
@aramos-adobe aramos-adobe added the S2 Spectrum 2 label Apr 23, 2025
Base automatically changed from aramos-adobe/css770-infield-button-s2-migration to spectrum-two April 24, 2025 15:58
Copy link
Contributor

@github-actions github-actions bot left a 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-gray-50",
"--spectrum-gray-700",
"--spectrum-gray-800",


[markdownlint-fix] reported by reviewdog 🐶

"--spectrum-negative-color-1100",


[markdownlint-fix] reported by reviewdog 🐶

"--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",

Copy link
Contributor

github-actions bot commented Apr 24, 2025

File metrics

Summary

Total size: 1.40 MB*
Total change (Δ): 🔴 ⬆ 0.16 KB (0.01%)

Table reports on changes to a package's main file. Other changes can be found in the collapsed Details section below.

Package Size Minified Gzipped Δ
combobox 26.19 KB 25.16 KB 3.01 KB 🟢 ⬇ 1.88 KB
helptext 7.05 KB 6.75 KB 1.15 KB 🔴 ⬆ 0.12 KB

File change details

combobox

Filename Head Minified Gzipped Compared to base
index.css 26.19 KB 25.16 KB 3.01 KB 🟢 ⬇ 1.88 KB
metadata.json 15.84 KB - - 🟢 ⬇ 0.03 KB

helptext

Filename Head Minified Gzipped Compared to base
index.css 7.05 KB 6.75 KB 1.15 KB 🔴 ⬆ 0.12 KB
metadata.json 3.87 KB - - 🔴 ⬆ 0.10 KB

tokens

Filename Head Minified Gzipped Compared to base
css/dark-vars.css 46.16 KB - - -
css/global-vars.css 78.26 KB - - -
css/index.css 253.13 KB - - 🔴 ⬆ 0.08 KB
css/large-vars.css 42.08 KB - - 🔴 ⬆ 0.04 KB
css/light-vars.css 46.16 KB - - -
css/medium-vars.css 42.21 KB - - 🔴 ⬆ 0.04 KB
json/tokens.json 396.47 KB - - -
* Size is the sum of all main files for packages in the library.
* An ASCII character in UTF-8 is 8 bits or 1 byte.

Copy link
Contributor

github-actions bot commented Apr 24, 2025

🚀 Deployed on https://pr-3683--spectrum-css.netlify.app

@aramos-adobe aramos-adobe force-pushed the aramos-adobe/css769-combox-s2-migration branch from a986db0 to ff02395 Compare April 24, 2025 20:26
@castastrophe castastrophe force-pushed the spectrum-two branch 3 times, most recently from 7e8269c to 4ce8d19 Compare May 5, 2025 21:18
@aramos-adobe aramos-adobe marked this pull request as ready for review May 6, 2025 18:14
@aramos-adobe aramos-adobe added ready-for-review size-5 L ~30-42hrs; lots of effort or complexity, most of a sprint needed to complete. run_vrt For use on PRs looking to kick off VRT labels May 6, 2025
@aramos-adobe aramos-adobe added skip_vrt Add to a PR to skip running VRT (but still pass the action) and removed run_vrt For use on PRs looking to kick off VRT labels May 6, 2025
@rise-erpelding rise-erpelding self-requested a review May 14, 2025 17:00
Copy link
Collaborator

@rise-erpelding rise-erpelding left a comment

Choose a reason for hiding this comment

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

This is an excellent start! I left several comments in the code, but here are some other considerations that didn't fit:

  • I did notice that there were autocomplete colors in the design spec, even though we can't (or shouldn't) implement any autocomplete functionality here, we probably should make sure we have the autocomplete styles in here, even if just with a selector like .spectrum-Combobox-input[autocomplete]. It looks like the textfield template has an autocomplete attribute that can be placed on the textfield input, so we could probably pass that arg to textfield from combobox once it's set up, and also wire up a Storybook control for it.
  • I think there might be a tiny design bug in the block spacing for the progress circle, I'll Slack you so that I can send screenshots and explain. This wasn't a part of the code you touched. (In fact there were several things I called out here that aren't related to changes you made but seemed like they've been wrong for awhile.)
  • Last thing: I saw this interaction error in Storybook, I don't think it's a huge issue, could be a follow up ticket if anything? (There is a role="presentation" so I'm not sure what it's complaining about)
    image

Copy link
Collaborator

@saashapina saashapina left a comment

Choose a reason for hiding this comment

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

This is looking great! I don't have access to the Figma Token Spec to give this a full review yet but I did just have a couple questions for myself. I also had my build fail in my PR after I rebased with the main spectrum-two branch. It looks it was missing a few metadata.json files.


### New mods

`--mod-combobox-line-height-cjk`
Copy link
Collaborator

Choose a reason for hiding this comment

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

This question is for future me, @castastrophe had mentioned to me that we were discontinuing use of mods. Are certain there scenarios like this that we will continue to support them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@saashapina @castastrophe I'm not entirely sure - I think that might be a web component related thing. But mods are still helpful for passthroughs between each component.

fieldLabelText: "Select location",
value: "Ballard",
};
Default.args = {};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also a question for my future reference, do we still need to define an empty object here if there are no args?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@saashapina I don't need this at all actually! I can remove it

Copy link
Collaborator

@rise-erpelding rise-erpelding left a 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.

isDisabled,
isReadOnly,
value,
...args,
...passthrough,
}, context),
content,
popoverWidth: size === "s" ? 140 : size === "l" ? 191 : size === "xl" ? 192 : 166, // default value is "m"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's valid that you're removing this but I looked into this for a bit and I'm having a hard time understanding why it was here to begin with. It looks like popoverWidth is used to control the width of the popover and align it with the popover width, but only if it's in certain popover positions. I would have thought it'd control the popover's width in combobox, but it seems like the popover position is such that it doesn't need the width (seems like we only use it in bottom-start position, which doesn't look at the width).

isQuiet,
customClasses: [`${args.rootClass}-popover`],
customStyles: {
"inline-size": size === "s" ? "192px" : size === "l" ? "224px" : size === "xl" ? "240px" : "208px",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, so this works to make the popover's width the same as the combobox textfield's, but it also doesn't work because we now get a horizontal scrollbar.

image

It actually looks pretty good if we remove the divider, so I'm wondering if that's the problem.

image

I'm wondering if a follow-up ticket is the best option here? It might involve adjustments to the Divider or Menu components' CSS, which feels out of scope here. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

we probably need to add this to the changeset since we're adjusting the CSS here

Comment on lines +142 to +143

--spectrum-help-text-to-component: 0px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was this token not working? It does appear to be in tokens correctly.

@@ -40,6 +39,7 @@
--spectrum-combobox-border-width: var(--spectrum-border-width-200);

--spectrum-combobox-spacing-label-to-combobox: var(--spectrum-field-label-to-component);
--spectrum-combobox-spacing-side-label-to-field: var(--spectrum-spacing-200);
Copy link
Collaborator

@rise-erpelding rise-erpelding May 19, 2025

Choose a reason for hiding this comment

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

OH I see now this is the one that you mentioned on Friday was missing from the spec. Good call!

/**
* Comboboxes have a read-only option for when content in the disabled state still needs to be shown. This allows for content to be copied, but not interacted with or changed. A combobox does not have a read-only option if no selection has been made. To enable this feature, add the `.isReadOnly` class to the combobox. To enable this feature, add the .isReadOnly class to the combobox. Then within the nested textfield component, add the .isReadOnly class and readonly attribute to the `<input>` element.
* Comboboxes have a read-only option for when content in the disabled state still needs to be shown. This allows for content to be copied, but not interacted with or changed. A combobox does not have a read-only option if no selection has been made. To enable this feature, add the `.is-readOnly` class to the combobox. To enable this feature, add the .isReadOnly class to the combobox. Then within the nested textfield component, add the .isReadOnly class and readonly attribute to the `<input>` element.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a nit putting .isReadOnly into code in a couple of places:

Suggested change
* Comboboxes have a read-only option for when content in the disabled state still needs to be shown. This allows for content to be copied, but not interacted with or changed. A combobox does not have a read-only option if no selection has been made. To enable this feature, add the `.is-readOnly` class to the combobox. To enable this feature, add the .isReadOnly class to the combobox. Then within the nested textfield component, add the .isReadOnly class and readonly attribute to the `<input>` element.
* Comboboxes have a read-only option for when content in the disabled state still needs to be shown. This allows for content to be copied, but not interacted with or changed. A combobox does not have a read-only option if no selection has been made. To enable this feature, add the `.is-readOnly` class to the combobox. To enable this feature, add the `.isReadOnly` class to the combobox. Then within the nested textfield component, add the `.isReadOnly` class and readonly attribute to the `<input>` element.

content = [],
value = "",
...args
} = {}, context = {}) => {
const popoverHeight = size === "s" ? 106 : size === "l" ? 170 : size === "xl" ? 229 : 142; // default value is "m"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to set the popoverHeight for the docs page? It looks like the "extra-large" heading is running into the popover above it, this might need adjusting if the height has changed.

image

Comment on lines +95 to +98
autocomplete: {
table: {
disable: true,
},
Copy link
Collaborator

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?

}
}

.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));
Copy link
Collaborator

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?

image image

}

/* TEXT INPUT */
.spectrum-Combobox-input {
background-color: var(--highcontrast-combobox-background-color-default, var(--mod-combobox-textfield-background-color, var(--spectrum-combobox-background-color-default)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, here's another thing that you didn't introduce in this PR that I'm wondering about:

.spectrum-Combobox-input and .spectrum-Textfield-input are the same element in combobox, right? But in some cases we use passthroughs by setting textfield mods to the tokens we want for combobox, and in other cases we're resetting/overriding the styles. In numberfield (#3681), Marissa used passthroughs wherever possible, but incorporating the infield buttons means that there were some things that just didn't work and she had to override some styles there. I think if anything, I'd recommend a similar approach here?

image

For instance I see that font-style, font-weight, and font-size don't use the mods for textfield, but are set on .spectrum-Combobox-input instead. Same with padding-block-start and padding-block-end, but we need a separate padding-inline-start and padding-inline-end so it seems ok to override padding-inline for textfield instead of using its mod.

And then background-color and line-height do have mods, but I'm not sure we can reach them from combobox because of where they were placed in the textfield css, so I think setting them on .spectrum-Combobox-input is the only option. 🤷‍♀️

I don't know what the right answer is since we can't use passthroughs for everything and sometimes we have to override styles, but it's confusing to set styles for the same element in two different places (here and up top in the passthroughs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-review S2 Spectrum 2 size-5 L ~30-42hrs; lots of effort or complexity, most of a sprint needed to complete. skip_vrt Add to a PR to skip running VRT (but still pass the action)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants