Skip to content
Snippets Groups Projects
Unverified Commit 9f4c2b3e authored by Anton Kulyk's avatar Anton Kulyk Committed by GitHub
Browse files

Fix native model results disappear when leaving query editor (#19739)

* Reproduce #19180

* Add `cancelQueryOnLeave` prop to NativeQueryEditor

* Don't cancel query when leaving model query editor
parent 5cf546a5
Branches
Tags
No related merge requests found
......@@ -114,6 +114,11 @@ function DatasetEditor(props) {
isInitiallyOpen
viewHeight={height}
hasParametersList={false}
// We need to rerun the query after saving changes or canceling edits
// By default, NativeQueryEditor cancels an active query on unmount,
// which can also cancel the expected query rerun
// (see https://github.com/metabase/metabase/issues/19180)
cancelQueryOnLeave={false}
/>
) : (
<ResizableNotebook
......
......@@ -84,6 +84,7 @@ export default class NativeQueryEditor extends Component {
static defaultProps = {
isOpen: false,
cancelQueryOnLeave: true,
};
UNSAFE_componentWillMount() {
......@@ -177,7 +178,9 @@ export default class NativeQueryEditor extends Component {
}
componentWillUnmount() {
this.props.cancelQuery();
if (this.props.cancelQueryOnLeave) {
this.props.cancelQuery();
}
document.removeEventListener("keydown", this.handleKeyDown);
document.removeEventListener("contextmenu", this.handleRightClick);
}
......
import { restore } from "__support__/e2e/cypress";
const QUESTION = {
native: { query: "select * from products" },
};
describe("issue 19180", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
cy.intercept("/api/card/*/query").as("cardQuery");
});
it("shouldn't drop native model query results after leaving the query editor", () => {
cy.createNativeQuestion(QUESTION).then(({ body: { id: QUESTION_ID } }) => {
cy.request("PUT", `/api/card/${QUESTION_ID}`, { dataset: true }).then(
() => {
cy.visit(`/model/${QUESTION_ID}/query`);
cy.wait("@cardQuery");
cy.button("Cancel").click();
cy.wait("@cardQuery");
cy.get(".TableInteractive");
cy.findByText("Here's where your results will appear").should(
"not.exist",
);
},
);
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment