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

SelectDropdown: cleanup code and migrate CSS to webpack #35086

Merged
merged 29 commits into from
Aug 16, 2019

Commits on Aug 16, 2019

  1. Configuration menu
    Copy the full SHA
    95ffe52 View commit details
    Browse the repository at this point in the history
  2. SelectDropdown: instanceId doesn't need to be in state and be used fo…

    …r keys
    
    Changes `instanceId` to be an instance property assigned during construction. No need
    to put it in state, as it never changes.
    
    Also, don't use `instanceId` to create `key` values. These don't need to be globally unique.
    Use them only for DOM element IDs that are used to link elements together with ARIA attributes.
    jsnajdr committed Aug 16, 2019
    Configuration menu
    Copy the full SHA
    552c6c3 View commit details
    Browse the repository at this point in the history
  3. SelectDropdown: remove props argument of getInitialSelectedItem

    We can always read from `this.props`. Even in constructor, because we
    called `super( props )`.
    jsnajdr committed Aug 16, 2019
    Configuration menu
    Copy the full SHA
    688328a View commit details
    Browse the repository at this point in the history
  4. SelectDropdown: comment and improve the getInitialSelectedItem logic

    Add comments about what the method does, and fix a bug where a separator
    item (specified as `null` in `options`) can potentially crash the `find`.
    jsnajdr committed Aug 16, 2019
    Configuration menu
    Copy the full SHA
    4deb266 View commit details
    Browse the repository at this point in the history
  5. SelectDropdown: toggle visibility of dropdown with visibility: hidden

    Removes need for smart `tabIndex` logic: hidden elements are automatically
    excluded from tab order.
    
    `visibility: hidden`, as opposed to `display: none`, still takes the element
    into account when doing layout. Therefore, the dropdown header will continue
    to have the width of the widest option in the list.
    jsnajdr committed Aug 16, 2019
    Configuration menu
    Copy the full SHA
    a1eb241 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    f0a736d View commit details
    Browse the repository at this point in the history
  7. SelectDropdown: use modern refs for focusing item links

    Replace string ref with a modern one, and create a `focusLink` instance method
    to provide API for the parent component that wants to set focus. Replace access
    to internal `itemRef.refs.itemLink` property.
    jsnajdr committed Aug 16, 2019
    Configuration menu
    Copy the full SHA
    461cc13 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    9295655 View commit details
    Browse the repository at this point in the history
  9. SelectDropdown: replace string itemRefs with modern ones

    Use an array of refs to focusable items, set them with a callback, move the `refIndex`
    increment inline to calling expression.
    jsnajdr committed Aug 16, 2019
    Configuration menu
    Copy the full SHA
    e4b2f58 View commit details
    Browse the repository at this point in the history
  10. SelectDropdown: cloned children don't need a key

    `key` is needed only when passing array of children. In this case, the children
    are written as JSX and `key` doesn't need to be added on cloning and mapping 1:1.
    jsnajdr committed Aug 16, 2019
    Configuration menu
    Copy the full SHA
    6f0f107 View commit details
    Browse the repository at this point in the history
  11. SelectDropdown: only DropdownItem children need to be cloned and amended

    Only `DropdownItem` needs a ref (it's focusable and the ref is used to move focus
    on up and down keyboard navigation) and an `onClick` handler. Separator and Label
    are neither focusable nor clickable.
    jsnajdr committed Aug 16, 2019
    Configuration menu
    Copy the full SHA
    bd515ee View commit details
    Browse the repository at this point in the history
  12. SelectDropdown: ignore clicks on Label and Separator, add a11y role

    Clicks on label and separator should not bubble to the parent element and
    cause the dropdown to close. This patch adds a missing handler to the separator
    component (label is already OK). Also adds an a11y role to specify that the element
    is not interactive despite having an `onClick` handler.
    jsnajdr committed Aug 16, 2019
    Configuration menu
    Copy the full SHA
    cf37742 View commit details
    Browse the repository at this point in the history
  13. SelectDropdown: simplify setting initial state

    Can be done by assinging an instance property instead of full constructor.
    Also, `getInitialSelectedItem` already handles the case where `options` prop
    is not present or empty.
    jsnajdr committed Aug 16, 2019
    Configuration menu
    Copy the full SHA
    55bfde9 View commit details
    Browse the repository at this point in the history
  14. SelectDropdown: remove unneeded componentWillReceiveProps

    Closing the popup when receiving new props doesn't seem to make much sense.
    And the initial selected value is set only on initial mount and further changes
    of the prop are ignored. That's the common behavior of initial-ish props on
    uncontrolled components. For example, native `<input defaultValue="x" />` renders
    input box with "x" and doesn't change the value on further rerenders with a different
    prop.
    jsnajdr committed Aug 16, 2019
    Configuration menu
    Copy the full SHA
    80c5256 View commit details
    Browse the repository at this point in the history
  15. SelectDropdown: no need to look at initial selected item in getSelect…

    …edText or Icon
    
    In the `getSelectedText` and `getSelectedIcon` getters, the currently selected value
    is always in `this.state.selected`. No need to default to the initial value.
    
    Also, use `_.get` instead of `_.result`, as `icon` and `label` are not functions.
    jsnajdr committed Aug 16, 2019
    Configuration menu
    Copy the full SHA
    6f4a029 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    1e34bbd View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    25fa960 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    b27fa72 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    9132ff1 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    fe294bc View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    e17e807 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    e258936 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    7012304 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    72f9842 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    1f27220 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    19023f0 View commit details
    Browse the repository at this point in the history
  27. SelectDropdown: update unit tests

    Some of them were quite awful, spying on internal method calls or mocking the whole component instance
    instead of testing on the real component and checking its state and JSDOM rendering.
    jsnajdr committed Aug 16, 2019
    Configuration menu
    Copy the full SHA
    b09fabe View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    dd17c67 View commit details
    Browse the repository at this point in the history
  29. SelectDropdown: hide the dropdown options when the dropdown is closed

    Otherwise, the options element is clickable although it has `visibility: hidden`
    and captures clicks on controls that are underneath it.
    jsnajdr committed Aug 16, 2019
    Configuration menu
    Copy the full SHA
    c9b3c11 View commit details
    Browse the repository at this point in the history