-
-
Notifications
You must be signed in to change notification settings - Fork 253
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 changing tabs closing query editor #1784
Conversation
@@ -130,8 +130,12 @@ export default function QueryEditor() { | |||
const { queries = [] } = appDom.getChildNodes(dom, page) ?? []; | |||
|
|||
const handleEditStateDialogClose = React.useCallback(() => { | |||
appStateApi.setView({ kind: 'page', nodeId: page.id }); | |||
}, [appStateApi, page.id]); | |||
if (!dialogState?.isDraft) { |
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.
Prefer positive logic
if (!dialogState?.isDraft) { | |
if (dialogState?.isDraft) { | |
setDialogState(null); | |
// ... |
if (currentView.kind === 'page' && currentView.view?.kind === 'query') { | ||
const node = appDom.getNode(dom, currentView.view?.nodeId, 'query'); | ||
return { node, isDraft: false }; | ||
} | ||
|
||
return null; | ||
if (!dialogState?.isDraft) { |
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.
Same,
if (!dialogState?.isDraft) { | |
if (dialogState?.isDraft) { | |
return previousState; | |
} | |
return null; |
}); | ||
}, [dom, currentView]); | ||
}, [dom, currentView, dialogState?.isDraft]); |
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.
Perhaps extract this in a variable and reuse?
const isDraft = !!dialogState?.isDraft;
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.
Few stylistic nits. Should we add/amend a test for this?
Not sure, this was quite a specific issue since it involves switching tabs. The |
I've modified the |
Closes #1742
margin: auto
in the page node.Screen.Recording.2023-03-22.at.20.03.43.mov