Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

fix falsey check when removing card embed from document (#65222)

Nick Fitzpatrick6fafafe0828f
diff --git a/e2e/test/scenarios/documents/card-embed-node.cy.spec.ts b/e2e/test/scenarios/documents/card-embed-node.cy.spec.ts
index 8e47197556a..08f112e09b8 100644
--- a/e2e/test/scenarios/documents/card-embed-node.cy.spec.ts
+++ b/e2e/test/scenarios/documents/card-embed-node.cy.spec.ts
@@ -430,6 +430,19 @@ describe("documents card embed node custom logic", () => {
});
describe("deleting a cardEmbed", () => {
+ it("should allow you to remove a card if it is the first item in a docuemnt (UXW-2169)", () => {
+ cy.visit("/document/new");
+
+ H.documentContent().click();
+ H.addToDocument("/ord", false);
+ H.commandSuggestionItem(/Orders, Count$/).click();
+
+ H.openDocumentCardMenu("Orders, Count");
+ H.popover().findByText("Remove Chart").click();
+
+ cy.findAllByTestId("document-card-embed").should("have.length", 0);
+ });
+
it("should delete a cardEmbed when selected and Backspace is pressed", () => {
H.createDocument({
name: "DnD Test Document",
diff --git a/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/HandleEditorDrop/utils.ts b/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/HandleEditorDrop/utils.ts
index a1fa6db9378..e6a6fcb3cd7 100644
--- a/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/HandleEditorDrop/utils.ts
+++ b/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/HandleEditorDrop/utils.ts
@@ -134,7 +134,7 @@ export const findNodeParentAndPos = (
}
});
- if (parentPos && parent) {
+ if (parentPos !== null && parent !== null) {
return { parentPos, parent };
}