feat(search): s2 migration#2673
Conversation
🦋 Changeset detectedLatest commit: ebc11c5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
|
🚀 Deployed on https://pr-2673--spectrum-css.netlify.app |
File metricsSummaryTotal size: 1.37 MB* Table reports on changes to a package's main file. Other changes can be found in the collapsed Details section below.
File change detailssearch
tokens
* An ASCII character in UTF-8 is 8 bits or 1 byte. |
f3dd9ff to
9931a8e
Compare
rise-erpelding
left a comment
There was a problem hiding this comment.
The CSS for this is looking so much cleaner and the testing preview matches several of the others that we've done! ✨ Here are a few visual things I noticed when going through this PR that might need some changes:
- The border for the disabled state is transparent but should have a gray color, it looks like there wasn't a
--modforborder-colorever set on the disabled state for textfield:
- I'm wondering if this might need an
.is-keyboardFocused:hoverselector, this hover state looks like it might be unintentional (it goes gray from black):
Other questions I have that were carryover from how the component was before:
- Is there a way to preview the search field with the help text? I know there's a spec for spacing the help text from the component, and I see that it's being used in the code, but I didn't see a way to view it in Storybook.
- Would it be helpful at all to have a control to show/not show the clear button? I was thinking if it wasn't showing by default I could check the
pill-edge-to-textspacing but then I realized that anytime it'd be used, the text would always be the placeholder "Search" text and the spacing between the end of that text box and the edge of the text field is a bit irrelevant. But is there any reason why anyone might want to look at the search field without the clear button instead of it always being there? - In WHCM, there's a clear color difference between the text color of the placeholder text and the text color when there's a value, it was like this before, and it's probably not a big deal, but it seemed a little odd to me so I thought I'd call it out:


There was a problem hiding this comment.
One thing I am wondering about is the focus and focus indicator on the clear button. In our Storybook, you can tab focus the field and then tab focus the clear button, which shows a rounded focus indicator:

I didn't see a design for that focus on the clear button to reference, and also took a look at the SWC search, which doesn't have it tab focusable (the field clears with the Esc key it seems). Is the intention for us to not have it as a tab stop?
6dbc850 to
ae7aedd
Compare
0871d58 to
2be2d4c
Compare
|
Thanks for the feedback! Some responses for Rise:
And a response for Josh:
|
e0e0fd2 to
698e904
Compare
cdb180d to
27d01df
Compare
c695845 to
589966f
Compare
rise-erpelding
left a comment
There was a problem hiding this comment.
This is mostly a pretty straightforward migration, and doesn't need a whole lot! There are some really nice additions/enhancements to the docs and testing template. The only remnants of the quiet variant in this component are in the changelog, which is expected. My notes:
- We'll want to do a rebase on this to include the textfield migration
- Definitely should clarify what we're ok with carrying over from textfield and what should be separately defined in search.
- Questioning the end spacing on the input, the token not being used there, and the clear button spacing specs.
- There was a small change in spec that we talked about separately where we want the keyfocus border color to be gray-800 instead of gray-900 to align with the colors of textfield... not a huge deal and we can wait for the "official" spec to change and follow up later if you think that's a better idea.
- Last thing - what is the minimised variant? I assume it's just like a search icon that you click on and then the search field appears? Do you think we'd need to do anything with that?
| - chore(textfield): add border-color custom property mod | ||
| - Search needed access to the disabled border-color in textfield, so the `--mod-textfield-border-color-disabled` custom property was added. |
There was a problem hiding this comment.
Hmmm, I'd like to understand why we were doing this previously and whether or not we think we still need it.
There's no impact to the border color either way; disabled-border-color is the border token we want for both textfield and search, and in any case, it evaluates to gray-300 which is the default border color token anyway. But is it ok that the disabled search textfield border is being set by textfield and not search? Is there a situation where we'd need it to be set in search, for instance if someone wants a --mod for this specific to search?
(I have the same question about the focus indicator tokens but will formally ask that somewhere else.)
There was a problem hiding this comment.
I'm not sure I'm totally following your question on the search border color. I do see this in all of the passthrough mods:
--mod-textfield-border-color-disabled: var(--mod-search-border-color-disabled, var(--spectrum-search-border-color-disabled));
Does that answer any of your questions? This seems to track with the pattern that was happening in this file, but I haven't come across many other migrations that seem to have done this same, mod-heavy approach. We might have to pair if I'm still not understanding.
| --spectrum-search-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); | ||
| --spectrum-search-focus-indicator-gap: var(--spectrum-focus-indicator-gap); | ||
| --spectrum-search-focus-indicator-color: var(--spectrum-focus-indicator-color); |
There was a problem hiding this comment.
Oh, great, I was looking for a place to comment on this, and here you've already commented on it! 🙂
I did notice that they were missing from the CSS file. It feels kind of unnecessary to me also though. The only instance where I think we'd it explicitly redefined that I can think of would be if someone wanted to set focus indicator styles differently for search in comparison to textfield, but that seems massively like an edge case.
I don't have a problem with them being removed but could be convinced if someone else has a strong argument for doing so.
| inputValue: { | ||
| name: "Display value and close button", | ||
| description: "When defined, this will display the input and the clear button within the search field.", |
There was a problem hiding this comment.
Could you set this arg to "" below (around L66) so the default doesn't say "Set string" or is there a specific reason you weren't?
There was a problem hiding this comment.
The close button also doesn't go away if I empty the textfield once I've typed into it. I can see the value of having the close button and value text bound together in a single control but it does make things a little weird, although you could argue maybe not weird enough to matter? This feels similar to other components where we've had radio or select controls and once you've picked one of them you can't go back to the initial state without resetting the controls.
There was a problem hiding this comment.
Good catch on the inputValue- thank you!
For the clear button....yeah that's a tricky one. If I use the inputValue controls, the clear button responds as I'm expecting- appearing when that inputValue is defined, and not appearing when inputValue is undefined. But there's a few issues if I actually use the component, like when I type into the search field itself, the button doesn't appear at all. I think you're right about this aspect of the component is stuck in that "resetting" issue we've found before.
Screen.Recording.2025-04-10.at.8.35.25.AM.mov
Should I leave an implementation note in the docs about the expected behavior? "Implementations should be sure that the clear button renders when an input value is defined, and does not render when that value is undefined" (or something like that?)
There was a problem hiding this comment.
You could and while I think as a precedent we do provide some basic guidance about how the component should behave, the argument could also be made that we're not the one-stop-shop for explaining all the things about the component and that implementations should probably still reference designs if they have further questions. I'll leave this one up to you! It's ok as is as far as I'm concerned.
| padding-block-start: calc(var(--mod-search-top-to-text, var(--spectrum-search-top-to-text)) - var(--mod-search-border-width, var(--spectrum-search-border-width))); | ||
| padding-block-end: calc(var(--mod-search-bottom-to-text, var(--spectrum-search-bottom-to-text)) - var(--mod-search-border-width, var(--spectrum-search-border-width))); | ||
| padding-inline-start: calc(var(--mod-search-edge-to-visual, var(--spectrum-search-edge-to-visual)) - var(--mod-search-border-width, var(--spectrum-search-border-width)) + var(--mod-search-icon-size, var(--spectrum-search-icon-size)) + var(--mod-search-text-to-icon, var(--spectrum-search-text-to-icon))); | ||
| padding-inline-end: calc(var(--mod-search-button-inline-size, var(--spectrum-search-button-inline-size)) - var(--mod-search-border-width, var(--spectrum-search-border-width))); |
There was a problem hiding this comment.
Is this the piece of padding between the text input and the edge?
I noticed we're not using component-pill-edge-to-text tokens here and I'm wondering why? Is it because we're trying to leave more space for the clear button?
But also the clear button isn't really spec'd inside of search at all, which feels odd to me, is there a reason for that, that you know of?
There was a problem hiding this comment.
Yes- the padding-inline-start should add space between the value & placeholder text and the search icon, and then the padding-inline-end should give space between the value in the input and the clear button (that's when it's most noticeable I think).
The --spectrum-search-edge-to-visual should be set to the component pill edge to text tokens for each t-shirt size. But if you're asking why aren't we using that in the padding-inline-end, I don't have a good answer for that. I'll have to get back with you.
I don't know why the clear button isn't spec'd, but I can certainly reach out to design and ask. All I can infer from the designs is that the clear button is all the way at the end of the search container. That's how the component seems to be styled currently as well.
jawinn
left a comment
There was a problem hiding this comment.
Here are a couple more suggestions.
589966f to
c9717c7
Compare
0e892ed to
7b5ec61
Compare
@rise-erpelding I have CSS-1158 written up for the minimized variant. When I last heard from Kami and Lynn, the file/branch for that variant was corrupted so Kami was in the midst of recreating I believe. The minimized search is basically just a search icon-only button, and when clicked, would expand the field, if I remember correctly. I can share Slack threads in a DM if you'd like! |
I did see that ticket at the last Backlog review, thanks!! No further details needed for now 🙂 |
rise-erpelding
left a comment
There was a problem hiding this comment.
Nothing else blocking for me!
This is minor, but I think the reviewdog stylelint comments might need addressing as I'm seeing those same lines underlined in my editor.
I think we discussed the keyfocus border color change somewhere at some point (we want it to be gray-800 like the mouse focus, not gray-900), I don't see that in here, but that's fine because the border colors match what's currently in the spec. Let's make a note to keep an eye out for a spec change here though since we were told unofficially that the value is wrong and we'll make the change then!
Nice work on this!
| inputValue: { | ||
| name: "Display value and close button", | ||
| description: "When defined, this will display the input and the clear button within the search field.", |
There was a problem hiding this comment.
You could and while I think as a precedent we do provide some basic guidance about how the component should behave, the argument could also be made that we're not the one-stop-shop for explaining all the things about the component and that implementations should probably still reference designs if they have further questions. I'll leave this one up to you! It's ok as is as far as I'm concerned.
| .spectrum-Search .spectrum-Search-textfield, | ||
| .spectrum-Search .spectrum-Search-textfield .spectrum-Search-input { | ||
| --highcontrast-search-color-default: CanvasText; | ||
| --highcontrast-search-color-hover: CanvasText; | ||
| --highcontrast-search-color-focus: CanvasText; | ||
| --highcontrast-search-color-disabled: GrayText; |
3e48b3f to
4eb0786
Compare
* chore: move forced colors to bottom for cascade * feat: token value adjustments and design spec alignment - rearranges where some of the textfield mods are (passthroughs) - adds styles for focus+hover in testing - clarifies where the custom properties are in the files - adds some missing tokens for block-start/block-end - removes whitespace in some of the style and/or mod declarations - reimplements custom --spectrum-corner-rounding-full token in global.vars after rebase - removes selectors that are not needed for the border color in key- boardFocus+hover, and colors in mouseFocus+hover states * chore: previous versions for migration guide - removes a stray isQuiet arg from stories * chore: update component name to align with design spec - also updates component name case * docs(search): show new options - remove quiet variant - adds help text story - adds inputValue to control table and corresponding behavior - fixes Search icon - clarify clear button language - add chromatic test coverage - adds aria-label based on guidance page in template - adds headings to SearchOptions template containers - hotfix for textfield's displayLabel arg - adds documentation from guidance page - clarifies some descriptions for args - adds default undefined string to inputValue * fix: token fix and removal of unused, keyboardfocus hover * docs(clearbutton): option to remove from focus for searchfield - remove unnecessary variant control * chore: update stylelint ignore comments - add stylelint disable comments & descriptions * chore(search,tokens): add changeset * chore(searchfield): update metadata * fix(search): fix focus+hover border in WHCM
2852b95 to
ebc11c5
Compare

Description
I believe this is blocked until we get the S2 icons.
S2 migration of Search to align with design specs. On top of the migration work, this PR includes:
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:
To-do list