Skip to content

DropDown Specification

Galina Edinakova edited this page Sep 14, 2021 · 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

Objectives

The igc-dropdown component extends the igc-toggle component and displays a list of selectable drop-down 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 drop-down 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(2/item);

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

<igc-dropdown @igcSelection="itemSelection"></igc-dropdown>

The igc-drop-down-item-group component can be used inside of the igc-drop-down to group igc-drop-down-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-drop-down>
      ${foods.map((item) => {
        return html`
        <igc-dropdown-item-group>
          ${item.name}
           ${item.entries.map((food) => {
            return html`
            <igc-drop-down-item>${food.name}<igc-drop-down-item>`
        </igc-dropdown-item-group>`
      })}
    </igc-drop-down>`;
  }

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 is changing the focus to the previous/next item but is not changing the selection. Pressing ENTER or SPACE key is closing the dropdown after the selection is changed.

Pressing the Esc key closes the dropdown without changing the selection. Pressing the Home key scrolls the list and sets the focus to the first selectable item (not disabled or header). Pressing the End key scrolls the list and sets the focus to the last selectable item.

3.4. API

Properties

IgcDropDownComponent

Name Description Type Default value Reflected
selectedItem Gets the selected item IgxDropDownItemComponent false
items Gets all non-header items IgxDropDownItemComponent[] false
headers Gets all header items IgxDropDownItemComponent[] false
?allowItemsFocus Allows items to take focus Boolean false
?width Sets/gets the tab width of the control String false
?height Sets/gets the tab height of the control String false
element Get dropdown html element HtmlElement false
collapsed Sets dropdown's visibility. Boolean true false
placement Sets the position of the dropdown. Placement bottom-start false
scrollStrategy Determines the behavior of the dropdown while scrolling the container. absolute | block | close | noop absolute false
modal Whether the dropdown is in modal state. Boolean false true
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(anchor). Boolean false 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 given item is disabled Boolean false true
focused Sets/gets if the given item is focused Boolean false true
?index Gets item index Number false
?element Get item html element HTMLElement false

Note: igc-dropdown-item API selected setter will not trigger the igcSelection event Note: if an igc-drop-down-item is inside of a disabled igc-drop-down-item-group, the disabled getter will always return true

IgcDropDownGroupComponent

Name Description Type Default value Reflected
disabled Sets/gets if the given item group is disabled. When true, disables all drop down items inside the group. Boolean false true

Methods

IgcDropDownComponent

Name Description Parameters
toggle Toggles the dropdown none
show Shows the dropdown none
hide Hides the dropdown none
select Select an item by index new selected item or item index

Events

IgcDropDownComponent

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

Note: igc-dropdown API select method will trigger the igcSelection event

Slots

Name Description
(default) Renders the dropdown's content

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
  • moving the focus up and down via the keyboard 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.
  • We will provide default value for min-width with CSS and will allow the users to set actual width property. There will not be a default max-width set, as it may differ per app-scenario.
  • (?)The igc-drop-down-item-group tag should be used only to group igc-drop-down-items. All other content will be disregarded by the IgcDropDownGroupComponent.

Automated

  • The dropdown shows all items properly
  • The dropdown is properly positioned according to the placement setting
  • The user should be able to select an item by 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 should 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 focused
  • Disabled items cannot be selected
  • Items do not loose focus when a disabled item is clicked
  • Drop down groups do render all items in them correctly
  • All drop down items in a disabled drop down group are also disabled

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