diff --git a/nx/public/plugins/quick-edit/src/selection.js b/nx/public/plugins/quick-edit/src/selection.js index 124fbb26a..76cc120fc 100644 --- a/nx/public/plugins/quick-edit/src/selection.js +++ b/nx/public/plugins/quick-edit/src/selection.js @@ -203,10 +203,23 @@ export function setupNodeSelection(ctx) { return; } - if (!currentSelectedNode) return; if (t.closest?.(OVERLAY_SELECTOR) || t.closest?.('picture') || t.closest?.('[data-prose-index]')) return; + + const block = t.closest?.('[data-block-index]'); + if (block) { + const node = blockSelectPayload(block); + if (!node) return; + if (currentSelectedNode?.anchorType === 'table' + && currentSelectedNode.proseIndex === node.proseIndex) return; + blurActiveEditor(); + clearHoverPill(); + activeCtx?.port?.postMessage({ type: MESSAGE_TYPES.NODE_SELECT, payload: { node } }); + return; + } + + if (!currentSelectedNode) return; const selectedEl = resolveSelectionElement(currentSelectedNode, document); if (selectedEl?.contains?.(t)) return; activeCtx?.port?.postMessage({ diff --git a/test/nx/public/plugins/quick-edit/selection.test.js b/test/nx/public/plugins/quick-edit/selection.test.js index c91ed9477..69a24c656 100644 --- a/test/nx/public/plugins/quick-edit/selection.test.js +++ b/test/nx/public/plugins/quick-edit/selection.test.js @@ -295,6 +295,15 @@ describe('quick-edit selection gestures', () => { expect(posted.some((m) => m.type === 'node-select' && m.payload?.node === null)).to.equal(false); }); + it('posts node-select when clicking a non-editable area inside a block directly', () => { + const block = document.querySelector('[data-block-index="60"]'); + block.dispatchEvent(new MouseEvent('mousedown', { bubbles: true })); + expect(posted).to.deep.include({ + type: 'node-select', + payload: { node: { anchorType: 'table', proseIndex: 60 } }, + }); + }); + it('clears the selection when clicking outside it', () => { setSelectedNode({ anchorType: 'table', proseIndex: 50 }); document.querySelector('.no-index')