You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The useBlocks hook is imported but never called, yet state.dispatch is used in the new effect. This will cause a runtime error because state is undefined.
The keyboard shortcut effect lists only designer in its dependencies but also uses state.dispatch. Missing dependencies can lead to stale closures or unintended behavior.
useEffect(()=>{consthandleKeyDown=(event: KeyboardEvent)=>{if((event.ctrlKey||event.metaKey)&&event.shiftKey&&(event.key==='x'||event.key==='X')){if(designer.selected){// Prevent deletion if id contains 'page'if(designer.selected.includes('page')){return;}// Delete the selected blockstate.dispatch({message: ActionMessages.REMOVE_BLOCK,payload: {id: designer.selected,keep: false,},});designer.setSelected('');}elseif(designer.selectedBlocks.length>0){// Delete all multiselected blocksdesigner.selectedBlocks.forEach((id: string)=>{if(!id.includes('page')){state.dispatch({message: ActionMessages.REMOVE_BLOCK,payload: {id: id,keep: false,},});}});designer.addBlockToSelected('clear');}event.preventDefault();event.stopPropagation();}};document.addEventListener('keydown',handleKeyDown);return()=>{document.removeEventListener('keydown',handleKeyDown);};},[designer]);
Calling addBlockToSelected('clear') misuses the API and adds a block with id "clear". Instead, explicitly clear the multi-selection with the proper method or setter.
Why: Calling addBlockToSelected('clear') likely introduces a phantom block, so explicitly clearing with setSelectedBlocks([]) fixes a real logic bug.
Medium
General
Refine page ID guard
Using includes('page') may block IDs that simply contain the string "page". Use a more precise check such as startsWith('page-') (or your actual prefix) to only guard true page IDs.
Why: Checking for 'page' via .includes may block unintended IDs, so using a precise prefix match prevents false positives.
Low
Simplify effect dependencies
Use an empty dependency array for the effect to avoid reattaching the keydown listener on every render and prevent stale closures. The MobX designer object reference is stable, so the handler will still see updated properties.
Why: Changing the effect to run only once improves performance by avoiding redundant listener reattachments without breaking the handler since the observable designer reference remains stable.
Low
Use lowercase key check
Normalize the key comparison by using event.key.toLowerCase() for a single case-insensitive check, reducing duplication and potential mistakes.
Keyboard shortcut (Ctrl + Shift + X) to delete single or multiple blocks.
to commit the new content to the CHANGELOG.md file, please type:
'/update_changelog --pr_update_changelog.push_changelog_changes=true'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User will be able to delete single block or multiple block using keyboard shortcut ctrl + shift + x