Skip to content
This repository has been archived by the owner on Oct 8, 2023. It is now read-only.

Update dependency downshift to v8 #339

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Jul 17, 2023

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
downshift (source) ^6.1.12 -> ^8.2.2 age adoption passing confidence

Release Notes

downshift-js/downshift (downshift)

v8.2.2

Compare Source

Bug Fixes
  • typescript: add onPress to toggle button props parameter (#​1548) (fd6ab68)

v8.2.1

Compare Source

Bug Fixes
  • defaultProps: use undefined environment on React Native (#​1546) (7d8c32d)
  • useSelect: preventDefault on item props onMouseDown (b24f2e6)
  • useSelect: preventDefault on item props onMouseDown (#​1547) (05ffa9c)

v8.2.0

Compare Source

Features

v8.1.1

Compare Source

Bug Fixes
  • typescript: missing generic parameter of React.RefObject (#​1536) (bc7639c)

v8.1.0

Compare Source

Features

v8.0.2

Compare Source

Bug Fixes

v8.0.1

Compare Source

Bug Fixes

v8.0.0

Compare Source

Features
BREAKING CHANGES
  • Release Downshift v8.

PRs included:

https://github.com/downshift-js/downshift/pull/1440
https://github.com/downshift-js/downshift/pull/1445
https://github.com/downshift-js/downshift/pull/1463
https://github.com/downshift-js/downshift/pull/1510
https://github.com/downshift-js/downshift/pull/1482

Changes

These changes will also be covered in the V8 migration guide.

isItemDisabled

Both useCombobox and useSelect now support the isItemDisabled function. This new API is used to mark menu items as disabled, and as such remove the from the navigation and prevent them from being selected. The old API required passing the disabled prop to the getItemProps function. This old API has been removed and you will receive a console warning if you are trying to use the disabled prop in getItemProps.

Example of API migration:

Old:

const items = [{value: 'item1'}, {value: 'item2'}]

const {getInputProps, ...rest} = useCombobox({items})

return (
  // ... rest
  <li {...getItemProps({item, disabled: item.value === 'item2'})}>
)

New:

const items = [{value: 'item1'}, {value: 'item2'}]

const {getInputProps, ...rest} = useCombobox({items, isItemDisabled(item, _index) { return item.value === 'item2' }})

return (
  // ... rest
  <li {...getItemProps({item})}>
)

The API for Downshift remains unchange.

useCombobox input click

ARIA 1.2 recommends to toggle the menu open state at input click. Previously, in v7, the menu was opened on receiving focus, from both mouse and keyboard. Starting with v8, input focus will not trigger any state change anymore. Only the input click event will be handled and will trigger a menu toggle. Consequently:

  • getInputProps will not return any Focus event handler.
  • getInputProps will return a Click event handler.
  • useCombobox.stateChangeTypes.InputFocus has been removed.
  • useCombobox.stateChangeTypes.InputClick has been added instead.

We recommend having the default toggle on input click behaviour as it's part of the official ARIA combobox 1.2 spec, but if you wish to override it and not toggle the menu on click, use the stateReducer:

function stateReducer(state, actionAndChanges) {
  const {changes, type} = actionAndChanges
  switch (type) {
    case useCombobox.stateChangeTypes.InputClick:
      return {
        ...changes,
        isOpen: state.isOpen, // do not toggle the menu when input is clicked.
      }
    default:
      return changes
  }
}

If you want to return to the v7 behaviour and open the menu on focus, keep the reducer above so you remove the toggle behaviour, and call the openMenu imperative function, returned by useCombobox, in a onFocus handler passed to
getInputProps:

<input
  {...getInputProps({
    onFocus() {
      openMenu()
    },
  })}
/>

Consider to use the default 1.2 ARIA behaviour provided by default in order to align your widget to the accessibility official spec. This behaviour consistency improves the user experience, since all comboboxes should behave the same and
there won't be need for any additional guess work done by your users.

Getter props return value types

Previously, the return value from the getter props returned by both Downshift and the hooks was any. In v8 we improved the types in order to reflect what is actually returned: the default values return by the getter prop function and
whatever else the user passes as arguments. The type changes are done in this PR, make sure you adapt your TS code, if applicable.

Also, in the Downshift component, the return values for some getter prop values have changed from null to undefined, since that is what HTML elements expect (value or undefined). These values are also reflected in the TS types.

  • getRootProps: 'aria-owns': isOpen ? this.menuId : nullundefined,
  • getInputProps:
    • 'aria-controls': isOpen ? this.menuId : nullundefined
    • 'aria-activedescendant': isOpen && typeof highlightedIndex === 'number' &&
      highlightedIndex >= 0 ? this.getItemId(highlightedIndex) : nullundefined
  • getMenuProps: props && props['aria-label'] ? nullundefined : this.labelId,
environment propTypes

The environment prop is useful when you are using downshift in a context
different than regular DOM. Its TS type has been updated to contain Node and
the propTypes have also been updated to reflect the properties which are
required by downshift from environment.

v7.6.2

Compare Source

Bug Fixes

v7.6.1

Compare Source

Bug Fixes

v7.6.0

Compare Source

v7.5.0

Compare Source

v7.4.1

Compare Source

Bug Fixes
  • useCombobox: Ensure highlighted index is not selected on browser tab change (#​1484) (4ff1385), closes #​1471

v7.4.0

Compare Source

Features

v7.3.4

Compare Source

Bug Fixes
  • defaultProps: only select if there are items and one is highlighted (#​1467) (108c1ba)

v7.3.3

Compare Source

Bug Fixes
  • hooks: correctly compute item and index in getter function (#​1473) (7471fba)

v7.3.2

Compare Source

Bug Fixes

v7.3.1

Compare Source

Bug Fixes

v7.3.0

Compare Source

Features

v7.2.2

Compare Source

Bug Fixes

v7.2.1

Compare Source

Bug Fixes
  • hooks: do not add mouse and touch events in React native (#​1472) (694f2af)

v7.2.0

Compare Source

Features

v7.1.2

Compare Source

v7.1.1

Compare Source

v7.1.0

Compare Source

Features
  • useSelect: improve highlight by character keys algorithm (#​1456) (d822530)

v7.0.5

Compare Source

Bug Fixes
  • add clean up to avoid effect firing twice in strict mode (#​1436) (25a673b)

v7.0.4

Compare Source

Bug Fixes

v7.0.3

Compare Source

Bug Fixes

v7.0.1

Compare Source

Bug Fixes

v7.0.0

Compare Source

Features
BREAKING CHANGES
  • updates to useCombobox and useSelect to adhere to the 1.2 version of the ARIA Combobox pattern.

Migration guide is available in this file.

Closes https://github.com/downshift-js/downshift/issues/1365.
Closes https://github.com/downshift-js/downshift/issues/1239.
Contains changes from https://github.com/downshift-js/downshift/pull/1149.


Configuration

📅 Schedule: Branch creation - "before 7am on Tuesday,before 7am on Wednesday" in timezone Australia/Melbourne, Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@changeset-bot
Copy link

changeset-bot bot commented Jul 17, 2023

⚠️ No Changeset found

Latest commit: 701e193

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants