Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 10 commits into from
Feb 13, 2025

Conversation

kendallgassner
Copy link
Contributor

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'

@Copilot Copilot AI review requested due to automatic review settings February 7, 2025 23:51
@kendallgassner kendallgassner requested a review from a team as a code owner February 7, 2025 23:51
Copy link

@Copilot Copilot AI left a 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

Copy link
Contributor

@camertron camertron left a 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?

@kendallgassner kendallgassner changed the title Allow a no-results option with role=none Allow a no-results option with role=presentation Feb 11, 2025
@kendallgassner kendallgassner marked this pull request as draft February 11, 2025 23:46
@kendallgassner kendallgassner marked this pull request as ready for review February 12, 2025 21:17
Base automatically changed from kendallg/add-npm-run-examples-back to main February 12, 2025 22:53
Copy link
Contributor

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

Great stuff

@kendallgassner kendallgassner merged commit 49d5f01 into main Feb 13, 2025
7 checks passed
@kendallgassner kendallgassner deleted the kendallg/allow-no-results branch February 13, 2025 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants