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

SelectControl: Add borderless prop #57720

Closed
jameskoster opened this issue Jan 10, 2024 · 12 comments · Fixed by #63265
Closed

SelectControl: Add borderless prop #57720

jameskoster opened this issue Jan 10, 2024 · 12 comments · Fixed by #63265
Assignees
Labels
[Package] Components /packages/components [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@jameskoster
Copy link
Contributor

jameskoster commented Jan 10, 2024

As noted in #57670, a couple of UI concepts in the data views work call for a SelectControl with reduced visual prominence. Two examples are; operator selection in filter configuration, and the page selector in pagination:

Screenshot 2024-07-08 at 14 03 57 Screenshot 2024-07-08 at 14 03 44

We can get halfway there by using the small size, but it would be good to have a built-in way to hide the border as well.

@jameskoster jameskoster added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components labels Jan 10, 2024
@ciampo
Copy link
Contributor

ciampo commented Jan 10, 2024

It looks like that border is inherited from InputControl. Is having borderless controls a need that we should consider for the wider group of controls in the package? (cc @mirka )

Not my area of expertise, but have we considered the potential accessibility implications of a borderless dropdown, especially for visually impaired users? (cc @andrewhayward )

@jameskoster
Copy link
Contributor Author

Is having borderless controls a need that we should consider for the wider group of controls in the package?

It seems unlikely there would be a need for other controls to omit the border, largely because they lose their identity with out one. A borderless SelectControl can work (in theory) because most of the time the chevron will be present and this helps indicate the purpose of the element.

Hopefully appropriate labelling, hover and focus styles can handle the accessibility requirements, but let's see what Andrew says.

@ciampo
Copy link
Contributor

ciampo commented Jan 11, 2024

@mirka in terms of APIs, what do you think about adding a variant prop with type undefined | 'unstyled' ?

@mirka
Copy link
Member

mirka commented Jan 11, 2024

@mirka in terms of APIs, what do you think about adding a variant prop with type undefined | 'unstyled' ?

It is a possibility, but we should first assess whether the borderless style makes sense with all the available sizes/paddings, labeling options, multiple, prefix/suffix, etc. If not (which I predict will be the case here), it would be a lot simpler to make a thin facade component with a limited subset of props.

@jameskoster
Copy link
Contributor Author

The use cases that have arisen essentially call for a select with a smaller footprint and less visual prominence. So the likelihood of the options you mention being required is minimal. If that points to a 'facade component' then I think it could work.

@ciampo
Copy link
Contributor

ciampo commented Jan 12, 2024

it would be a lot simpler to make a thin facade component with a limited subset of props.

That's also a possibility. Do you think that component should live in @wordpress/components ?

@mirka
Copy link
Member

mirka commented Jan 18, 2024

Do you think that component should live in @wordpress/components ?

Yes, I think it's pretty generic. We can keep it locked while we work out the requirements.

@ciampo
Copy link
Contributor

ciampo commented Jan 26, 2024

I think we can treat #58195 as a place to experiment with such a component's requirements, especially when striking the balance between minimal looks and accessibility.

@mirka
Copy link
Member

mirka commented Jul 8, 2024

@jameskoster I'm working on this right now, and I have some important questions about the adaptive width.

All the mockups for this borderless variant suggest that we want the select width to adapt to the width of the currently selected option.

  • Q1: How critical is this styling feature?

    • To implement this for all browsers now, we need to add a bit of JS complexity (inject a hidden select with only the selected option, get its computed width, then explicitly set the width of the actual select).
    • There is a CSS field-sizing property in the pipeline that does exactly what we want, and it's shipping in Chrome but we're still waiting on Safari and Firefox. (They are both planning to implement it though.)
    • It is trivial to achieve a rough width fit, where the select width is equal to the longest option in the set.

    Is it acceptable to use field-sizing in Chrome and fall back to a rough width fit on other browsers until it's implemented? Or is it critical to have an exact fit on all browsers right now?

  • Q2: Will we always want this fit when isBorderless?

  • Q3: May we sometimes want to use this fit when not borderless?

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jul 8, 2024
@jameskoster
Copy link
Contributor Author

This style variant is typically for cases where the select should be less visually prominent, so yes I think ideally the width of the resting state should 'hug' the chosen value. It's probably important from an a11y standpoint too... if the chevron is too far from the value then the nature of the control is less obvious.

Perhaps we start with field-sizing, and await feedback from Safari / Firefox users?

Q2: Will we always want this fit when isBorderless?

I would say so, yes.

Q3: May we sometimes want to use this fit when not borderless?

I can't think of a situation where we would right now.

@ciampo
Copy link
Contributor

ciampo commented Jul 9, 2024

Slightly unrelated, but should we have a variant prop instead of a boolean borderless prop? That would probably give us more flexibility in the future.

@mirka
Copy link
Member

mirka commented Jul 9, 2024

Slightly unrelated, but should we have a variant prop instead of a boolean borderless prop? That would probably give us more flexibility in the future.

I was considering keeping the border a separate boolean if we're going to allow "à la carte" styling with the width hugging, but since we're going to couple the borderless styles with width styles, I think it's better to do variant like you said.

@jasmussen jasmussen moved this from Now to In Dev in Design priorities Jul 10, 2024
@github-project-automation github-project-automation bot moved this from In Dev to Done in Design priorities Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants