Skip to content
Open
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
15 changes: 14 additions & 1 deletion nx/public/plugins/quick-edit/src/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
9 changes: 9 additions & 0 deletions test/nx/public/plugins/quick-edit/selection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Loading