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

Make prefocusFirstItem behavior configurable and consistent #242

Conversation

chrisregner
Copy link
Contributor

@chrisregner chrisregner commented Feb 8, 2024

Problem

Most of the time, this component tends to prefocuses first suggestion. This is done in a way that in not configurable and slightly inconsistent. For example, if you want to match behavior of Google Autocomplete on this aspect, you can't (GAC doesn't prefocus first item).

Before Change

  • It prefocuses first item in most cases
    • On initially render
    • On query change
    • On open
    • NOT on filter out of currently focused item

After Change

  • When prefocusFirstItem is true (default)
    • On initially render
    • On query change
    • On open
    • On on filter out of currently focused item
  • When false
    • Do not prefocus on all events above

Copy link

changeset-bot bot commented Feb 8, 2024

⚠️ No Changeset found

Latest commit: 0fd02b7

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.

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

Copy link

what-the-diff bot commented Feb 8, 2024

PR Summary

  • Addition of New Property 'prefocusFirstItem' to 'AutoComplete' Component
    A new property named 'prefocusFirstItem' has been added to the 'AutoComplete' component. By default, this property is set to 'true'.

  • Introduction of New Property 'onReady' to 'AutoComplete' Component
    The 'AutoComplete' component now has a new property called 'onReady'.

  • Inclusion of New Property 'onTagRemoved' to 'AutoComplete' Component
    Another new property, 'onTagRemoved', has been added to the 'AutoComplete' component.

  • Addition of 'shouldRenderSuggestions' to 'AutoComplete' Component
    The 'AutoComplete' component now also includes the new property 'shouldRenderSuggestions'.

  • Update to the 'Item' Interface in 'types.ts' File
    The 'Item' interface in the 'types.ts' file has been updated for improved functionality.

  • Modifications to 'useAutoComplete' Function
    The 'useAutoComplete' function in the 'use-autocomplete.ts' file has been updated to handle the new properties and enhanced functionality of the 'AutoComplete' component.

@Kysluss Kysluss added the enhancement New feature or request label Feb 10, 2024
@Kysluss
Copy link
Collaborator

Kysluss commented Feb 10, 2024

@chrisregner Thank you for the feature suggestion and the PR. I like this functionality and agree it makes it more in line with other auto completes out there while leaving the current behavior as the deafult. I'm going to merge this and it will be in the next release with credit to you. I should have a new version out by end of tomorrow. I'm working on 1 other issue at the moment that I'll bundle into this.

@Kysluss Kysluss merged commit fe3693d into anubra266:main Feb 10, 2024
1 check passed
@Kysluss
Copy link
Collaborator

Kysluss commented Feb 11, 2024

v5.3.0 has been released with credit to you for this. Let me know if you find any issues. Thank you so much for the PR. I will be updating the contributors list shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants