-
Notifications
You must be signed in to change notification settings - Fork 54
Allow a no-results option with role=presentation #126
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This pull request adds support for keeping the popover open by treating an element with data-no-result-found="true" as an alternative indicator for a valid state. Key changes include updating the logic that determines if there are results to incorporate elements with the no-results attribute.
Changes
File | Description |
---|---|
src/autocomplete.ts | Modified hasResults logic to also check for elements with data-no-result-found="true". |
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
src/autocomplete.ts:214
- [nitpick] The 'hasResults' variable now accounts for two different conditions, which may be misleading. Consider renaming it to something that better reflects its dual purpose, such as 'hasValidOptions'.
!!allNewOptions.length || !!this.results.querySelectorAll('[data-no-result-found="true"]').length
Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 😄 I agree we should have some tests for this. Would you also mind sticking a blurb in the README about the "no results" feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff
Adding in the ability to keep the popover open if a user has an item with
data-no-result-found="true"
.This is particularly useful if engineers want to give visual indication that there are no results without using role='option'