Closed bangank36 closed 1 year ago
Demostration for the logic at hasMultiSelection() check
Using git blame to check for this issue
Selecting across blocks is possible by temporarily setting the
contentEditable
attribute totrue
- Shift+Arrow make the container
contenteditable
, reference- Since the selection is updated by browser,
useSelectionObserver
is called- multiSelect is dispatched
- onSelectionChange logic
- When a richtext is selected selectionChange action is fired SELECTION_CHANGE
- In turn reducer selection will update the store
- 'SELECTION_CHANGE' - 'RESET_SELECTION' - 'MULTI_SELECT' - 'RESET_BLOCKS'
- So we need to investigate the mechanism of the 'MULTI_SELECT' action? Answer: it is explain above, the browser select the blocks and Gutenberg will read the selection based on selectionchange event
None Spacer Block | Tiptap |
---|---|
if ( element.contains( focusNode ) &&
element !== focusNode
)
if ( element.contains( anchorNode ) &&
element !== anchorNode
)
contenteditable
attribute so I tried following things
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
<div tabindex="0" class="block-editor-block-list__block wp-block wp-block-spacer" id="block-31f574e0-5066-4e0f-9769-215d86731f91" role="document" aria-label="Block: Spacer" data-block="31f574e0-5066-4e0f-9769-215d86731f91" data-type="core/spacer" data-title="Spacer" style="height: 100px;"><div class="components-resizable-box__container block-library-spacer__resize-container" style="position: relative; user-select: auto; width: auto; height: auto; min-height: 0px; box-sizing: border-box; flex-shrink: 0;"><div><div class="components-resizable-box__handle components-resizable-box__side-handle components-resizable-box__handle-bottom" style="position: absolute; user-select: none; cursor: row-resize;"></div></div></div></div>
wp-block-spacer
-> Working correctnpm run test:e2e:playwright -- test/e2e/specs/editor/blocks/spacer.spec.js
npm run test:e2e:playwright -- test/e2e/specs/editor/various/multi-block-selection.spec.js
Get caught in the issue
[webkit] › editor/various/multi-block-selection.spec.js:24:2 › Multi-block selection › should partially select with shift + click (@webkit)
Error: browserContext.newPage: Target closed
editor/various/multi-block-selection.spec.js
editor/blocks/spacer.spec.js
npm run test:e2e:playwright -- --update-snapshots test/e2e/specs/editor/various/copy-cut-paste.spec.js
Staled
Staled
Get started with development
*. Wordpress development enviroment
local
for WP instancegit clone https://github.com/WordPress/gutenberg.git
npm install
npm run dev
Summary
Insights
useArrowNav()
is fired when the Shift Arrow pressedisClosestTabbableABlock()
:closestTabbable
returns correct the next spacer blockfocus
and has a caret, when use Shift arrow it selects correctly, breakpoint stops atif ( hasMultiSelection() ) {
Reference