-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List v2: add forward delete #42564
List v2: add forward delete #42564
Conversation
Size Change: -189 B (0%) Total Size: 1.26 MB
ℹ️ View Unchanged
|
replaceBlocks( | ||
[ listItemParentId ], | ||
[ newListItemParent, ...newBlocksExcludingLast, newLastItem ] | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jorgefilipecosta @ntsekouras I cleaned up outdenting to use moveBlocksToPosition
. This has the benefit of keeping block client IDs and having to reapply selection. It's also a lot simpler and easier to follow.
packages/block-library/src/list-item/hooks/use-outdent-list-item.js
Outdated
Show resolved
Hide resolved
const clientIds = _hasMultiSelection | ||
? getMultiSelectedBlockClientIds() | ||
: [ clientId ]; | ||
useCallback( ( clientIds = getSelectedBlockClientIds() ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hook useOutdentListItem( clientId ) already receives a clientId parameter. It feels strange that the callback the hook returns ignores the parameter and receives a similar parameter can we just make the hook receive clientIds defaulting to getSelectedBlockClientIds and keep the callback without parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I'm following here. The default is to outdent the selected blocks (clientIds = getSelectedBlockClientIds()
), but we also need the ability to outdent specific blocks for forward Delete (outdent the next block).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments/questions, but everything works great. Awesome work, @ellatrix 👍
What?
Adds the ability to forward delete from the end of a list item. If the next line can be outdented, it will first be outdented. If it's at the top level, it will be merged.
Why?
Feature parity with List v1.
How?
Testing Instructions
Try forward delete (Fn+Backspace) from various positions.
Screenshots or screencast