Skip to content

fix: doc-explorer search combobox null checks #4024

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LBPeterson
Copy link

This PR adds a null check to fix a bug in the doc explorer that happens when the search field loses focus when there is no text in the search input. To reproduce in the Graphiql live demo:

  • Open the browser console
  • Open the Documentation Explorer (upper left)
  • Start searching in the pane
  • Delete your search term and click away from the search bar
  • See the console log this error: Uncaught TypeError: right-hand side of 'in' should be an object, got null

The cause:
The headlessui combobox is nullable by default in ^2, a change in api from ^1 Our existing onChange handler does not expect null values to be passed

The fix:
Add an early null check to the onChange handler

This PR adds a null check to fix a bug in the doc explorer that happens when the search field loses focus when there is no text in the search input.
To reproduce in the [Graphiql live demo](https://graphql.github.io/swapi-graphql/):
- Open the browser console
- Open the Documentation Explorer (upper left)
- Start searching in the pane
- Delete your search term and click away from the search bar
- See the console log this error: `Uncaught TypeError: right-hand side of 'in' should be an object, got null`

The cause:
The headlessui combobox is nullable by default in ^2, a change in api from ^1
Our existing onChange handler does not expect null values to be passed

The fix:
Add an early null check to the onChange handler
Copy link

changeset-bot bot commented Jun 17, 2025

🦋 Changeset detected

Latest commit: 6a8d630

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphiql/plugin-doc-explorer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

linux-foundation-easycla bot commented Jun 17, 2025

CLA Not Signed

Copy link
Collaborator

@dimaMachina dimaMachina left a comment

Choose a reason for hiding this comment

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

Thanks, I fixed it in v5 as well

Copy link
Collaborator

@dimaMachina dimaMachina left a comment

Choose a reason for hiding this comment

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

Can you sign CLA?

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.

2 participants