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

don't invoke callback on empty changes #2565

Merged
merged 1 commit into from
Jul 13, 2022
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
5 changes: 5 additions & 0 deletions .changeset/real-avocados-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphiql/react': patch
---

Don't invoke editor change callbacks when manually signaling "empty" changes.
11 changes: 10 additions & 1 deletion packages/graphiql-react/src/editor/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,16 @@ export function useChangeHandler(
updateActiveTabValues({ [tabProperty]: value });
});

const handleChange = (editorInstance: CodeMirrorEditor) => {
const handleChange = (
editorInstance: CodeMirrorEditor,
changeObj: EditorChange | undefined,
) => {
// When we signal a change manually without actually changing anything
// we don't want to invoke the callback.
if (!changeObj) {
return;
}

const newValue = editorInstance.getValue();
store(newValue);
updateTab(newValue);
Expand Down