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

fix search dropdown click #3364

Merged
merged 5 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/lemon-snakes-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'graphiql': patch
'@graphiql/react': patch
---

Fix search result bug on select, #33307
8 changes: 4 additions & 4 deletions packages/graphiql-react/src/explorer/components/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ export function Search() {
},
[push],
);
const [isFocused, setIsFocused] = useState(false);
const isFocused = useRef(false);
const handleFocus: FocusEventHandler = useCallback(e => {
setIsFocused(e.type === 'focus');
isFocused.current = e.type === 'focus';
}, []);

const shouldSearchBoxAppear =
Expand Down Expand Up @@ -110,8 +110,8 @@ export function Search() {
/>
</div>

{/* hide on blur */}
{isFocused && (
{/* display on focus */}
{isFocused.current && (
<Combobox.Options data-cy="doc-explorer-list">
{results.within.length +
results.types.length +
Expand Down
2 changes: 2 additions & 0 deletions packages/graphiql/cypress/e2e/docs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ describe('GraphiQL DocExplorer - search', () => {
});

it('Closes popover when blurring input', () => {
cy.dataCy('doc-explorer-input').focus();
cy.dataCy('doc-explorer-input').type('list');
cy.dataCy('doc-explorer-input').blur();
cy.dataCy('doc-explorer-list').should('not.exist');
});
Expand Down