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

Keep focus inside of the <ComboboxInput /> component #3073

Merged
merged 16 commits into from
Apr 3, 2024

Commits on Apr 2, 2024

  1. Configuration menu
    Copy the full SHA
    0777e18 View commit details
    Browse the repository at this point in the history
  2. use mousedown instead of click event

    The `mousedown` event happens before the `focus` event. When we
    `e.preventDefault()` in this listener, the `focus` event will not fire.
    
    This also means that the focus is not lost on the actual `input`
    component which in turn means that we can maintain the selection /
    cursor position inside the `input`.
    
    We still use the `refocusInput()` as a fallback in case something else
    goes wrong.
    RobinMalfait committed Apr 2, 2024
    Configuration menu
    Copy the full SHA
    cd851d9 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a973f43 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    135b0b8 View commit details
    Browse the repository at this point in the history
  5. ensure we handle Enter and Space explicitly

    Now that we use the `mousedown` event instead of the `click` event, we
    have to make sure that we handle the `enter` and `space` keys
    explicitly.
    
    This used to be covered by the `click` event, but not for the `mousedown` event.
    RobinMalfait committed Apr 2, 2024
    Configuration menu
    Copy the full SHA
    f30343e View commit details
    Browse the repository at this point in the history
  6. ensure we focus the first element when using ArrowDown on the `Comb…

    …oboxButton`
    
    We go to the last one on `ArrownUp`, but we forgot to do this on
    `ArrowDown`.
    RobinMalfait committed Apr 2, 2024
    Configuration menu
    Copy the full SHA
    35ed5dc View commit details
    Browse the repository at this point in the history
  7. fix tiny typo

    Not related to this PR, but noticed it and fixed it anyway.
    RobinMalfait committed Apr 2, 2024
    Configuration menu
    Copy the full SHA
    16e57b6 View commit details
    Browse the repository at this point in the history
  8. update changelog

    RobinMalfait committed Apr 2, 2024
    Configuration menu
    Copy the full SHA
    da5ef56 View commit details
    Browse the repository at this point in the history
  9. ensure we reset the isTyping flag

    While we are typing, the flag can remain true. But once we stop typing,
    the `nextFrame` handler will kick in and set it to `false` again.
    
    It currently behaves as a debounce-like function such that the
    `nextFrame` callbacks are cancelled once a new event is fired.
    RobinMalfait committed Apr 2, 2024
    Configuration menu
    Copy the full SHA
    64832a7 View commit details
    Browse the repository at this point in the history
  10. ensure unique callbacks in the _disposables array

    This allows us to keep re-adding dispose functions and only register the
    callbacks once.
    
    Ideally we can use a `Set`, but we also want to remove a single callback
    if the callback is disposed on its own instead of disposing the whole
    group. For this we do require an `idx` which is not available in a
    `Set` unless you are looping over all disposable functions.
    RobinMalfait committed Apr 2, 2024
    Configuration menu
    Copy the full SHA
    258baba View commit details
    Browse the repository at this point in the history

Commits on Apr 3, 2024

  1. Update packages/@headlessui-react/src/components/combobox/combobox.tsx

    Co-authored-by: Jonathan Reinink <jonathan@reinink.ca>
    RobinMalfait and reinink committed Apr 3, 2024
    Configuration menu
    Copy the full SHA
    59bea45 View commit details
    Browse the repository at this point in the history
  2. Update packages/@headlessui-react/src/components/combobox/combobox.tsx

    Co-authored-by: Jonathan Reinink <jonathan@reinink.ca>
    RobinMalfait and reinink committed Apr 3, 2024
    Configuration menu
    Copy the full SHA
    ac30fc3 View commit details
    Browse the repository at this point in the history
  3. update comments

    RobinMalfait committed Apr 3, 2024
    Configuration menu
    Copy the full SHA
    3e42d7d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    4b68e63 View commit details
    Browse the repository at this point in the history
  5. use correct path import

    RobinMalfait committed Apr 3, 2024
    Configuration menu
    Copy the full SHA
    4fed338 View commit details
    Browse the repository at this point in the history
  6. add some breathing room

    RobinMalfait committed Apr 3, 2024
    Configuration menu
    Copy the full SHA
    7dcd4ac View commit details
    Browse the repository at this point in the history