Stop a locked canvas layer from being reordered or displaced [#1248]#1347
Open
claytonlin1110 wants to merge 1 commit into
Open
Stop a locked canvas layer from being reordered or displaced [#1248]#1347claytonlin1110 wants to merge 1 commit into
claytonlin1110 wants to merge 1 commit into
Conversation
…1248] The summary copy promises "Lock brand elements so they cannot move by accident," but the Up/Down buttons only disabled at the top/bottom of the stack — a locked layer could still be moved directly, and an unlocked neighbour's Up/Down could displace it by swapping positions, since a single step only ever swaps with the adjacent layer. Extract canMoveLayer()/reorderLayers() as pure, exported functions: a move is allowed only when neither the layer being moved nor its target neighbour is locked. Both the button disabled-state and the actual move() now go through the same check, so a locked layer can never move and can never be displaced.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
prototype/canvas-layer-controls.html's summary copy promises "Lock brand elements so they cannot move by accident," but locking a layer only disabled its Remove button. The Up/Down buttons only disabled at the very top/bottom of the stack, with no check forlockedat all.canMoveLayer(list, index, delta)/reorderLayers(list, index, delta)as pure, exported functions: a move is allowed only when neither the layer being moved nor its target neighbour is locked. Both the buttondisabledstate and the actualmove()now go through the same check, andreorderLayersnever mutates its input.Why this is useful
Closes issue #1248 (filed against this exact gap: "Locking a canvas layer doesn't stop it being reordered or displaced, despite the lock's stated purpose"). Small, self-contained, single-file fix with a pure, directly-testable function pair — not navigation/routing, and not the active
bl:active-stepissue (#1326), so it's submitted independently of that scope per current repo direction.Verification
npm test— 104/104 smoke test files passprototype/canvas-layer-controls.test.js:reorderLayersreturns a new array on an allowed move and the same reference (no-op) on a refused one, without mutating the inputConflict avoidance
prototype/canvas-layer-controls.html(two new pure functions + three call sites) plus an extension of its existing test file. No nav, shell, or other screen files touched.