-
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
Add mechanism to avoid forced child selection on blocks with templates. #10696
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -652,14 +652,18 @@ export function blockSelection( state = { | |
end: action.clientId, | ||
initialPosition: action.initialPosition, | ||
}; | ||
case 'INSERT_BLOCKS': | ||
return { | ||
...state, | ||
start: action.blocks[ 0 ].clientId, | ||
end: action.blocks[ 0 ].clientId, | ||
initialPosition: null, | ||
isMultiSelecting: false, | ||
}; | ||
case 'INSERT_BLOCKS': { | ||
if ( action.updateSelection ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For me, this is not what's causing the innerBlocks to be selected, it's the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But the children are inserted after the parent, so without this changes, the selection gets updated when the child blocks are inserted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh makes sense. Seems like a decent approach. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @youknowriad thank you for looking into this PR. Do you think it is ready to merge? |
||
return { | ||
...state, | ||
start: action.blocks[ 0 ].clientId, | ||
end: action.blocks[ 0 ].clientId, | ||
initialPosition: null, | ||
isMultiSelecting: false, | ||
}; | ||
} | ||
return state; | ||
} | ||
case 'REMOVE_BLOCKS': | ||
if ( ! action.clientIds || ! action.clientIds.length || action.clientIds.indexOf( state.start ) === -1 ) { | ||
return state; | ||
|
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.
I wonder if this is really needed or if it should always be "false"?
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.
I think it needs to be conditional. If you're building a nested block with a flow optimised for writing you would want the selection to be updated for keyboard use.
Making it always false would also be a change in the current behaviour, which updates the selection automatically.
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.
I agree for some blocks it may make sense to use a different setting.
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.
Would this be clearer if it's named:
updateSelectionOnTemplateInsert
?