-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Update last inserted block state to track multiple blocks #46885
Changes from 4 commits
afaf6a2
d1aeb57
7aba184
61c7137
78e2d45
8ad7090
a528159
b5de919
c74eaf1
e14860f
7fe3070
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 |
---|---|---|
|
@@ -2647,7 +2647,7 @@ export const __experimentalGetActiveBlockIdByBlockNames = createSelector( | |
export function wasBlockJustInserted( state, clientId, source ) { | ||
const { lastBlockInserted } = state; | ||
return ( | ||
lastBlockInserted.clientId === clientId && | ||
lastBlockInserted.clientIds?.includes( clientId ) && | ||
lastBlockInserted.source === source | ||
); | ||
} | ||
|
@@ -2658,8 +2658,11 @@ export function wasBlockJustInserted( state, clientId, source ) { | |
* @param {Object} state Global application state. | ||
* @return {string|undefined} Client Id of the last inserted block. | ||
*/ | ||
export function getLastInsertedBlockClientId( state ) { | ||
return state?.lastBlockInserted?.clientId; | ||
export function __experimentalGetLastInsertedBlockClientId( state ) { | ||
return ( | ||
state?.lastBlockInserted?.clientIds?.length && | ||
state?.lastBlockInserted?.clientIds[ 0 ] | ||
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. We could update this selector to return all the clientIds and allow the user to deal with which one they want to count as the "last" or "latest". So if there is a single block you'd then consume it thus
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. I think we should return the array. 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. Agreed, picking the first one is very arbitrary 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. Excellent. We have a consensus. So I assume we:
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. I'm going to follow the guidance and advice in the docs 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. Ok I have now:
I still don't know if the new selector should be experimental. @draganescu felt there was no need as it was in use by the offcanvas. But that itself is an experiment so ... 🤷♂️ Opinions appreciated. 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. I vote we keep it experimental for now. |
||
); | ||
} | ||
|
||
/** | ||
|
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 idea here is to preserve the intent of the existing selector as if the block has just been inserted then it will stil be a valid result.