Page MenuHomePhabricator

Add Select/Dropdown component to Codex
Closed, ResolvedPublic

Description

Existing Components

MediaWiki Community:

External Libraries

Wikimedia Design Style Guide Links

Figma

Native HTML equivalent

Implementation notes

  • This component implies the creation of some related "menu" and "option" or "item" components that appear when the select/dropdown is expanded
  • The inner components should be re-usable in other similar contexts (autocomplete input, "comboboxes", buttons with dropdown indicators, etc)
  • Previous implementations have often expected some kind of rich items property representing data for the various options, but are we better off using <slots> to do this?
  • Usage with v-model should be typical; users should be able to bind the active item as a v-model value from the parent
  • Should support the same accessibility behaviors as the native <select> element
  • Properties this component needs to support potentially include: label, disabled, icon, and some kind of error-handling prop
  • A re-usable clickOutside composition function may need to be introduced here

UX Questions

One question that has come up during code review is: should this component allow the user to unset a previously set value, either in all cases or on a case-by-case basis?

Consider the following use-case: search filters in Commons MediaSearch.

The MediaSearch UI provides a series of search filter dropdowns that users can set to narrow their results by file type, image size, license, etc. The default label of these filters also doubles as the label for the entire dropdown: "File Type", "Image Size", "Community Assessment", etc.

Screen Shot 2021-12-10 at 10.50.38 AM.png (2×2 px, 3 MB)

Choosing an option within the dropdown closes the menu and sets the label to the currently-chosen value, as expected.

Screen Shot 2021-12-10 at 10.50.43 AM.png (2×2 px, 3 MB)

However, the user also needs a way to un-set these values so that they can get back to the full set of search results. The MediaSearch UI does this by providing an initial option within each menu that is labeled "All". When this option is clicked, the menu closes as before but "All" is never displayed as the label of the collapsed menu (the way "JPEG" was previously). Instead the default label for the dropdown is shown. Similarly, when the menu is expanded, the "All" option is never styled in a way to indicate that it has been selected. It is treated differently from the other options and is a little bit sneaky.

All of the filter dropdowns in MediaSearch exhibit this behavior. But there is another dropdown at the end of the set that breaks the pattern: the dropdown that controls sort order. Unlike with filters, where "no selection" is a valid choice that the user may want to get back to, when it comes to sorting the choice is strictly binary: either sort by relevance OR sort by recency. There is no "sort by nothing". One of the two options must always be selected, and the menu actually shows "relevance" as pre-selected when the user opens the menu for the first time.

Screen Shot 2021-12-10 at 10.51.11 AM.png (2×2 px, 3 MB)

I think it would be good for us to have clear answers for the following questions:

  • Should dropdown menus allow a selection to be unset? Should they all do this or should it be opt-in (per-dropdown)?
  • How should the user unset the value? Should there be an option within the value that corresponds to "no selection"?
  • Should the "no selection" option be treated the same as other options (gets the selection styles when chosen, replaces the initial default label), or does it require special treatment?
  • Should the user be able to unset a menu by clicking the selected option again (either instead of the above approach or in addition to it)?

The MediaSearch example is one way this could be handled but I don't necessarily think we should follow that here. However I do think similar use cases will come up elsewhere and we'll need a way to handle them.


Prior discussion for WVUI here: T280712: Add basic select list (dropdown) component to WVUI


To do

Design Review (see T295506#7854705 for more details)

  • Selector with start icon variant is missing
  • We should add the configurable selector demo with the following props:
    • With start icon
    • Without icon
    • Disabled selector
    • Customizable text (to test the maximum example)
  • Chevron icon should be Dropdown-Up when you open the menu (this is something that we didn't have implemented in OOUI but I think it's worth implementing) We finally won't implement the rotation for the dropdown icon (more details here)
  • Disabled state: delete clickable action and focus outline (details here)
  • On small screens (less than 380px screens on mobile) the component sticks out the demo box

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

I've done the Design Review of the component and I've found the following corrections:

  1. Selector with start icon variant is missing

Captura de pantalla 2022-04-14 a las 11.29.09.png (294×2 px, 119 KB)

  1. We should add the configurable selector demo with the following props:
    • With start icon
    • Without icon
    • Disabled selector
    • Customizable text (to test the maximum example)
  2. Chevron icon should be Dropdown-Up when you open the menu (this is something that we didn't have implemented in OOUI but I think it's worth implementing)

Captura de pantalla 2022-04-14 a las 11.31.08.png (618×886 px, 212 KB)

You can view the Figma with the select component spec sheet here.

I'm going to create a Design Review section in the task description with this checklist.

STH renamed this task from Add Select/Dropdown component to Codex to Add Select/Dropdown component to Codex [Ready for Development].Apr 15 2022, 5:19 PM
STH moved this task from Inbox to Needs Refinement on the Design-System-Team board.

@Catrope @AnneT moving this to the new board. Seems close to done? We can review in task refinement/planning - thanks!

STH renamed this task from Add Select/Dropdown component to Codex [Ready for Development] to [Ready for Development] Add Select/Dropdown component to Codex.Apr 15 2022, 8:32 PM

This needs some refinement still, but for now we decided to put it in the sprint and get started on the parts that are clear.

SimoneThisDot changed the task status from Open to In Progress.Apr 27 2022, 9:30 AM
SimoneThisDot claimed this task.
SimoneThisDot subscribed.

I am going to work on the design comments for now, while I gather further information on what was discussed in refinement.

Change 787514 had a related patch set uploaded (by Simone Cuomo; author: Simone Cuomo):

[design/codex@main] Select: Apply design review feedback

https://gerrit.wikimedia.org/r/787514

I have opened a patch with the following changes:

Design Review (see T295506#7854705 for more details)

  • Selector with start icon variant is missing
  • Chevron icon should be Dropdown-Up when you open the menu
  • Create configurable demo with / Without start icon
  • Create configurable demo with Disabled selector
  • Create configurable demo with Customizable text (to test the maximum example)

Change 787514 merged by jenkins-bot:

[design/codex@main] Select: Apply design review feedback

https://gerrit.wikimedia.org/r/787514

I've done the Design Sign-Off and all items from the Design Review checklist have been fixed (I've checked them in the list).

Captura de pantalla 2022-05-03 a las 17.01.13.png (544×2 px, 387 KB)

Only one thing, something is happening with the mobile version of the demo and the selector is bigger than the demo box.

Captura de pantalla 2022-05-03 a las 16.18.21.png (1×642 px, 338 KB)

I've done the Design Review of the component and I've found the following corrections:

  1. Chevron icon should be Dropdown-Up when you open the menu (this is something that we didn't have implemented in OOUI but I think it's worth implementing)

Captura de pantalla 2022-04-14 a las 11.31.08.png (618×886 px, 212 KB)

One detail out of a conversation with Simone on a related icon detail: We (as Foundation Product Design team) have deliberately settled on leaving the down arrow icon untouched by the Select's (dropdown's) state, for several reasons:

  • The icons shouldn't change on a button/button like interface element on click for better user orientation.
  • The change would distract from the actual area that should be in user focus, the menu item and the chosen value.
  • The icon change from down to up icon is only awkwardly transitioned, due to its graphical attributes it'd never be a smooth transition

If we were to change it, we would have to change it in a huge number of places across our interfaces, it took a while to get it standardized to consistent down in the past.
With arguments above I also pledge not to change it, it would not be the advantageous design.

STH renamed this task from [Ready for Development] Add Select/Dropdown component to Codex to Add Select/Dropdown component to Codex.May 4 2022, 5:19 PM
STH changed the task status from In Progress to Stalled.

Updated status for design team to discuss

To be discussed further and decided in this week's DS design sync meeting

Volker_E changed the task status from Stalled to In Progress.May 26 2022, 6:22 PM

From today's DST design sync meeting, we've come to agreement that it's better due to the points brought up in T295506#7900523 and additionally due to we cannot be sure which direction (top or bottom) the menu appears across the viewport in future Codex menu behavior

image.png (404×1 px, 41 KB)
, the arrow will remain unchanged when menu is opened.

Also just realized, that the new enabled/disabled selector logic originally in T302209 is not yet followed in Select leading to issues like

image.png (106×594 px, 10 KB)

(focus outline on disabled state)

Change 800484 had a related patch set uploaded (by VolkerE; author: VolkerE):

[design/codex@main] Select: Remove arrow indicator direction change when menu is expanded

https://gerrit.wikimedia.org/r/800484

Design Sign-Off done to check the dropdown icon updated without rotation.

Captura de pantalla 2022-05-27 a las 10.34.51.png (930×1 px, 487 KB)

Also just realized, that the new enabled/disabled selector logic originally in T302209 is not yet followed in Select leading to issues like

image.png (106×594 px, 10 KB)

(focus outline on disabled state)

@SimoneThisDot as @Volker_E comments, the disabled state shouldn't be clickable and currently you can click on it and a focus outline appears. We should fix it so I'm going to updated the To do section in the task description and move the task to Ready for Development to fix it.

Captura de pantalla 2022-05-27 a las 10.33.47.png (1×1 px, 447 KB)

Change 800484 merged by jenkins-bot:

[design/codex@main] Select: Remove arrow indicator direction change when menu is expanded

https://gerrit.wikimedia.org/r/800484

Change 800788 had a related patch set uploaded (by VolkerE; author: VolkerE):

[design/codex@main] Select, styles: Introduce `.cdx-select--enabled` class and align states

https://gerrit.wikimedia.org/r/800788

@bmartinezcalvo the only reason to provide the screenshot and my comment above in T295506#7962395 was to verbalize the design shortcoming 👍🏼 . Have started to work on the fix yesterday, that goes hand-in-hand with a former development agreement in T302209 for all our components. Fixing patch 800788 (patch demo) is up for review.

Moving back to design sign-off now that the disabled state issue appears to be fixed.

Technically, the a disabled Select still receives focus when you click it (or when you use the Tab key to move focus to it), but there's no visual indication that it's focused. This behavior differs from e.g. Button, which is not focusable (and skipped in the Tab order) when disabled. If we want to make this consistent, we could set the tabindex attribute of the handle div to be -1 when the component is disabled (we currently set tabindex=0 unconditionally).

Change 800788 merged by jenkins-bot:

[design/codex@main] Select, styles: Introduce `.cdx-select--enabled` class and align states

https://gerrit.wikimedia.org/r/800788

Design Sign Off Done:

  • Disabled state was fixed ✅
  • On small screens (less than 380px screens on mobile) the Select component doesn't fit the demo box, so it sticks out of the box. Updated task to fix it. ❌

Captura de pantalla 2022-05-31 a las 11.06.57.png (1×1 px, 571 KB)

Food for though: iOS team has been already pushing out the 320-375 canvas with technological progress. It's questionable if we should continue our 320px optimizations.

Food for though: iOS team has been already pushing out the 320-375 canvas with technological progress. It's questionable if we should continue our 320px optimizations.

@Volker_E what we should fix here is not the demo on 320px screens (that is broken in most of the cases) but the select component fitting the demo box. Should we fix it in this task or should we wait until 320-375 is fixed for all demo views?

ldelench_wmf subscribed.

Moving from sprint board to backlog per our defined goals at sprint planning; please holler if there's a reason to bump up the priority.

This happens because we have min-width: 280px on the dropdown, to prevent it from being too narrow. This causes it to grow outside of its box if the box is narrower than 280px.

Using natural sizing for dropdowns isn't a great option, because the default label (the text shown if nothing is selected) is optional, and because we don't want the dropdown to change size a different option is selected.

Instead, we could consider the approach that OOUI uses for its DropdownWidget, which is to make dropdowns width: 100% (meaning they take up the full width of their container), with a max-width so they don't get too wide (OOUI uses max-width: 50em which is 700px, but I think we could use a much lower value).

The above would also address T310399: Select: Entering a long default label extends the component's maxLength, which happens because we don't set a max-length on Select at all currently.

Volker_E removed a project: Patch-For-Review.
Volker_E updated the task description. (Show Details)

The Select follows for most parts the ARIA APG pattern, hence checking off the last open point on accessibility behavior.
Two accessibility follow-ups filed under
T342824: Select: Screen reader support doesn't work on SSRed demo page and
T347662: Select: Space opens dropdown, but also scrolls the page Note, that native select doesn't support Menu item selection by Space.

Resolving this task as part of Codex v0.1.0-alpha.1 initial release.