Skip to content

DropDown Specification

Galina Edinakova edited this page Jan 13, 2022 · 27 revisions

DropDown Specification

Contents

  1. Overview
  2. User Stories
  3. Functionality
  4. ARIA support
  5. Assumptions and Limitations
  6. Test scenarios
  7. References
  8. Dependencies

Owned by

Team Name: CodeX

Developer Name: Galina Edinakova

Designer Name:

Requires approval from

  • Peer Developer Name | Date:
  • Design Manager Name | Date:

Signed off by

  • Radoslav Mirchev| Date:
  • Radoslav Karaivanov | Date:

Revision History

Version Users Date Notes
1 Galina Edinakova 13-Sep-2021
2 Galina Edinakova 9-Dec-2021
3 Galina Edinakova 13-Jan-2022

Objectives

The igc-dropdown component uses the igcToggle directive and displays a list of selectable dropdown items. The igc-dropdown should display a scrollable list of items which may be visually grouped. Clicking an item should select it and close the drop down. The igc-dropdown should appear above all other in-app UI elements.

Developer Stories

As a developer, I want to

  • select an item
  • be notified, when selection has changed
  • be able to tie the dropdown to any kind of anchor.
  • open the dropdown within the viewport.
  • set the width of the dropdown.
  • set the height, and if it is exceeded a vertical scroll should appear.
  • default opening positions (Top start, Top end, Bottom start, Bottom end, attempt to vertically align the currently selected anchor with the list item.)
  • be able to group hierarchical data in groups without the need to flatten it?
  • to be able to set small, medium or large size to the dropdown and its items

As an end user, I want

  • to see a dropdown list of available choices
  • to have (or not have) a default selection
  • to select a choice using a mouse click
  • to select a choice using the SPACE and ENTER keys
  • to see the dropdown above all other elements on the page
  • to scroll the list of choices if they are too many
  • to be able to scroll navigate through the items using Up/Down arrow keys and Home/End keys.
  • to see the choices grouped if applicable
  • to close the dropdown by selecting an item or by pressing the ESC key
  • the dropdown to preserve selection
  • to have visual clue if a choice from the list is not selectable
  • to have visual clue if a choice from the list is selected, focused or hovered.
  • to change the selected values indefinitely, so that I can change my choice.
  • to have dropdown opening positions that are meaningful and dependent on my needs.
  • to have separators in the dropdown list, so that I have the items organized depending on my needs.
  • when the item content/text is too long to cut it and add ... to fit the available width (ellipsis).

3.1. End User Experience

Users are able to select an item from a predefined list of items which is displayed in the application UI.

3.2. Developer Experience

Developers are able to select items programatically like:

igcDropDown.select(value);

Developers can also subscribe to an event emitted before the item selection is completed:

<igc-dropdown @igcSelect="selectionHandler"></igc-dropdown>

The igc-dropdown-group component can be used inside the igc-dropdown to group igc-dropdown-items. The example below illustrates how to display hierarchical data in drop down groups:

    // in example.ts
    export class MyExampleComponent {
        ...
        foods: any[] =  [{
            name: 'Vegetables',
            entries: [{
                    name: 'Cucumber',
                    refNo: `00000` 
                }, {
                    name: 'Lettuce',
                    refNo: `00001`
                },
                ...
            ]   
        }, {
            name: 'Fruits',
            entries: [{
                    name: 'Banana',
                    refNo: `10000` 
                }, {
                    name: 'Tomato',
                    refNo: `10001`
                },
                ...
            ]   
        }];
    }
    <!-- example.ts -->
   render() {
    return html`<igc-dropdown>
      ${foods.map((item) => {
        return html`
        <igc-dropdown-group>
          ${item.name}
           ${item.entries.map((food) => {
            return html`
            <igc-dropdown-item>${food.name}<igc-dropdown-item>`
        </igc-dropdown-group>`
      })}
    </igc-dropdown>`;
  }

3.3. Keyboard Navigation

The default way to select an item from the dropdown is by mouse click. Keyboard selection is done using the ENTER and SPACE keys. Pressing UP and DOWN keys activates the previous/next item but is not changing the selection. Pressing ENTER or SPACE key is closing the dropdown after changing the selection.

Pressing the Enter key when focus is in the target shows the dropdown list. Pressing the Esc key closes the dropdown without changing the selection. Pressing the Home key scrolls the list and activates the first selectable item (not disabled or header). Pressing the End key scrolls the list and activates the last selectable item.

Note: The dropdown itself has not tabIndex and is not focusable by default. This way we allow the dropdown's target to keep the focus if necessary.

3.4. API

Properties

IgcDropDownComponent

Name Description Type Default value Reflected
open Sets dropdown's visibility. Boolean false false
placement Sets the position of the dropdown. Placement bottom-start false
strategy The positioning strategy to use. 'absolute' | 'fixed' 'absolute' false
scrollStrategy Determines the behavior of the dropdown while scrolling the container. absolute | block | close | noop absolute false
flip Whether to adjust dropdown's position based on the available space. Boolean true false
closeOnOutsideClick Whether the dropdown should close on clicking outside of it or its target. Boolean false false
offset The amount of offset in horizontal and/or vertical direction. { x: number, y: number } none false

IgcDropDownItemComponent

Name Description Type Default value Reflected
selected Sets/Gets if the item is the currently selected one in the dropdown Boolean false true
disabled Sets/gets if the item is disabled Boolean false true
active Sets/gets if the item is active Boolean false true
value The item's value. If not specified, defaults to the text content. String none true

Note: igc-dropdown-item API selected setter will not trigger the igcSelect event.

Methods

IgcDropDownComponent

Name Description Parameters
toggle Toggles the dropdown none
show Shows the dropdown none
hide Hides the dropdown none
select Selects an item by value new value
?clearSelection Clears current selection none

Events

IgcDropDownComponent

Name Description Cancelable Parameters
igcSelect Emitted when item selection is changing, before the selection completes true {ISelectionEventArgs}
igcOpening Emitted before the dropdown is opened true
igcOpened Emitted after the dropdown is opened false
igcClosing Emitted before the dropdown is closed true
igcClosed Emitted after the dropdown is closed false

Note: igc-dropdown select method will not trigger the igcSelect event.

Slots

IgcDropDownComponent

Name Description
target Renders the target element
(default) Renders the dropdown's content

IgcDropDownItemComponent

Name Description
(default) Renders the dropdown item's content
prefix Renders the dropdown item's prefix
suffix Renders the dropdown item's suffix

IgcDropDownHeaderComponent

Name Description
(default) Renders the dropdown header item's content

IgcDropDownGroupComponent

Name Description
(default) Renders the dropdown group's content
label Renders the dropdown group's label

We provide the aria-selected property which lets the screen readers know if an item is selected or not.

The following components gets the corresponding aria attributes

  • the only mode of selection will be single
  • keyboard navigation with arrow keys will not change selection.
  • Pressing the Esc key will close the dropdown, but will not update the selection.
  • Dropdown will not handle page up and page down key actions.

Automated

  • The dropdown shows all items properly
  • The dropdown is properly positioned according to the placement settings
  • The user should be able to select an item by pressing SPACE/ENTER keys and by click
  • The user can navigate through the items using Up/Down/Home/End keys
  • The dropdown should support disabled items
  • The items can be disabled/enabled at runtime
  • The dropdown should support headers
  • The dropdown should notify when the selection has changed
  • The dropdown should persist selection through scrolling
  • The Escape key should close the dropdown and not change the selection
  • The dropdown should not change selection when setting it to non-existing item
  • Home key should focus the first enabled and non-header item
  • End key should focus the last enabled and non-header item
  • Key navigation through disabled items should skip the disabled items
  • Width and height can be changed at run-time
  • Disabled items cannot be activated
  • Disabled items cannot be selected
  • Items do not lose focus when a disabled item is clicked
  • Drop down groups do render all items in them correctly

Manual

  • The dropdown shows/hides in a timely manner with a big number of items
  • Focus is changed in a timely manner when navigating via keyboard
  • The user may have more than one dropdown controls on the same page.
  • The dropdown content should not "flicker" when opening

https://material-components-web.appspot.com/select.html https://material.angular.io/components/select/overview https://material.angular.io/components/menu/overview https://material.io/guidelines/components/menus.html#menus-simple-menus

The igc-dropdown component depends on Popper and utilizes its positioning capabilities.

Clone this wiki locally