mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
fix: improve performance of connecting blocks (#6876)
* fix: early return from updateDisabled if it is noop * chore: trigger connect and disconnect before hiding * chore: remove disconnectInternal * fix: skip setting parent when disconnecting before connecting * chore: fixup docs * chore: remove erroneous test * fix: add delay to context menu callback. Improve INP by allowing the browser to do a paint (closing the context menu) before we trigger callbacks. This improves the user experience for expensive callbacks (e.g. collapsing, or updating disabled). * fix: rendering bug When disconnecting the last block in the stack, the block would not be rerendered correctly (the top-start corner would not be reshaped) * fix: connecting bug The order for applying connections was changed so that connections were applied and then the insertion marker was hidden. This caused an error because hiding the insertion marker expected there to be a child block when there was not. * chore: remove setParent param from public API * chore: tsdoc
This commit is contained in:
@@ -117,11 +117,15 @@ function populate_(
|
||||
if (option.enabled) {
|
||||
const actionHandler = function() {
|
||||
hide();
|
||||
// If .scope does not exist on the option, then the callback will not
|
||||
// be expecting a scope parameter, so there should be no problems. Just
|
||||
// assume it is a ContextMenuOption and we'll pass undefined if it's
|
||||
// not.
|
||||
option.callback((option as ContextMenuOption).scope);
|
||||
requestAnimationFrame(() => {
|
||||
setTimeout(() => {
|
||||
// If .scope does not exist on the option, then the callback
|
||||
// will not be expecting a scope parameter, so there should be
|
||||
// no problems. Just assume it is a ContextMenuOption and we'll
|
||||
// pass undefined if it's not.
|
||||
option.callback((option as ContextMenuOption).scope);
|
||||
}, 0);
|
||||
});
|
||||
};
|
||||
menuItem.onAction(actionHandler, {});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user