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

⬆️ deps: Upgrade dependency downshift to v9. #822

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

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Mar 21, 2024

Mend Renovate

This PR contains the following updates:

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

Release Notes

downshift-js/downshift (downshift)

v9.0.4

Compare Source

Bug Fixes

v9.0.3

Compare Source

Bug Fixes

v9.0.2

Compare Source

Bug Fixes

v9.0.1

Compare Source

Bug Fixes

v9.0.0

Compare Source

Features
BREAKING CHANGES
  • Release Downshift v9.

Why:
Release the changes in:

Closes https://github.com/downshift-js/downshift/issues/1322.
Closes https://github.com/downshift-js/downshift/issues/1244.
Closes https://github.com/downshift-js/downshift/issues/1227
Closes https://github.com/downshift-js/downshift/issues/1225.

How:
Merged the PRs in this branch.

Checklist:

  • Documentation
  • Tests
  • TypeScript Types
  • Flow Types
  • Ready to be merged

v8.5.0

Compare Source

Features

v8.4.0

Compare Source

Features

v8.3.3

Compare Source

Bug Fixes
  • fixes issue causing combobox to grab focus on render (#​1575) (59366d9)

v8.3.2

Compare Source

Bug Fixes

v8.3.1

Compare Source

Bug Fixes

v8.3.0

Compare Source

Features

v8.2.4

Compare Source

Bug Fixes

v8.2.3

Compare Source

Bug Fixes

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.


Configuration

📅 Schedule: Branch creation - "after 10pm every weekday,before 5am every weekday,every weekend" (UTC), 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.

@renovate renovate bot added the deps This issue has to do with dependencies label Mar 21, 2024
Copy link

codecov bot commented Mar 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.22%. Comparing base (61c921e) to head (303bea4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #822      +/-   ##
==========================================
- Coverage   66.56%   66.22%   -0.35%     
==========================================
  Files         696      696              
  Lines        9678     9678              
  Branches     1334     1334              
==========================================
- Hits         6442     6409      -33     
- Misses       2743     2785      +42     
+ Partials      493      484       -9     
Flag Coverage Δ
test 69.72% <ø> (ø)
test-app 55.83% <ø> (-0.40%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires manual intervention to migrate to the new API: https://togithub.com/downshift-js/downshift/blob/master/src/hooks/MIGRATION_V8.md

@make-github-pseudonymous-again make-github-pseudonymous-again added the requires-manual-intervention This automatically created PR requires manual intervention before merging. label Mar 22, 2024
@renovate renovate bot changed the title ⬆️ deps: Upgrade dependency downshift to v9 ⬆️ deps: Upgrade dependency downshift to v9. Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deps This issue has to do with dependencies requires-manual-intervention This automatically created PR requires manual intervention before merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant