feat: preview state styles during canvas drags - #684
Conversation
When a state variant is active, canvas drag handles now read and write the active style key instead of falling back to the base style. This keeps rotation, resize, spacing, movement and border radius previews aligned with the selected state.
Confidence Score: 3/5The core drag-to-state wiring works correctly for pixel-based styles, but the move handler has a unit-stripping bug that corrupts percentage-positioned state styles on drag. The frontend/src/components/BlockEditor.vue — the Reviews (1): Last reviewed commit: "fix: preview state styles during canvas ..." | Re-trigger Greptile |
| const activeLeft = props.block.getActiveStyleValue("left"); | ||
| const activeTop = props.block.getActiveStyleValue("top"); | ||
| const startLeft = hasStyleValue(activeLeft) | ||
| ? getNumberFromPx(activeLeft) | ||
| : (props.target as HTMLElement).offsetLeft || 0; | ||
| const startTop = hasStyleValue(activeTop) | ||
| ? getNumberFromPx(activeTop) | ||
| : (props.target as HTMLElement).offsetTop || 0; |
There was a problem hiding this comment.
If the active state's
left/top is a percentage (e.g. "50%"), getNumberFromPx returns 0 (it only strips "px"), so the drag starts from 0 and overwrites the % value with 100px-style pixels. BoxResizer handles this with a blockStartWidth?.includes("%") guard; the same logic is needed here — or simply keep offsetLeft/offsetTop as the start since the state style is already applied to the DOM.
| const activeLeft = props.block.getActiveStyleValue("left"); | |
| const activeTop = props.block.getActiveStyleValue("top"); | |
| const startLeft = hasStyleValue(activeLeft) | |
| ? getNumberFromPx(activeLeft) | |
| : (props.target as HTMLElement).offsetLeft || 0; | |
| const startTop = hasStyleValue(activeTop) | |
| ? getNumberFromPx(activeTop) | |
| : (props.target as HTMLElement).offsetTop || 0; | |
| const startLeft = (props.target as HTMLElement).offsetLeft || 0; | |
| const startTop = (props.target as HTMLElement).offsetTop || 0; |
| @@ -100,6 +100,7 @@ const transforming = computed(() => resizing.value || rotating.value); | |||
| const guides = setGuides(props.target, canvasProps); | |||
| const moving = ref(false); | |||
| const preventCLick = ref(false); | |||
When a state variant is active, canvas drag handles now read and write the active style key instead of falling back to the base style. This keeps rotation, resize, spacing, movement and border radius previews aligned with the selected state.
Screen.Recording.2026-07-20.at.4.50.17.PM.mov