Commit 2632b5f
authored
feat(ui): allow cmd+click on style panel items to skip next-shape style updates (tldraw#8452)
In order to let users make one-off style changes without affecting
defaults for future shapes, this PR adds accelerator key (Cmd on Mac /
Ctrl on Windows/Linux) modifier support to all style panel controls.
When the modifier is held while shapes are selected, the style change
applies only to those shapes and does not update `stylesForNextShape` or
`opacityForNextShape`. Closes tldraw#8431.
The implementation checks `editor.inputs.getAccelKey()` directly in
`StylePanelContext`, which provides both `onValueChange` (for styles)
and a new `onOpacityChange` (for opacity). This keeps the modifier logic
centralized — no changes needed in individual picker components.
### Change type
- [x] `feature`
### Test plan
1. Select a shape on the canvas
2. Click a color in the style panel — verify it changes the shape AND
updates the default for new shapes
3. Select another shape, hold Cmd (Mac) / Ctrl (Win/Linux) and click a
different color — verify it changes the shape but new shapes still use
the previous default
4. Test the same with opacity slider, fill, dash, size, font, geo,
arrowhead, and spline pickers
5. Test drag-to-paint (pointer down + drag across items) with Cmd held —
verify modifier is respected throughout the drag
- [ ] Unit tests
- [ ] End to end tests
### Release notes
- Add accelerator key modifier (Cmd on Mac / Ctrl on Windows/Linux) to
style panel items to apply styles to selected shapes only, without
changing the default style for new shapes.
### API changes
- Added `StylePanelContext.onOpacityChange(opacity: number)` —
centralizes opacity change handling with the same modifier-key behavior
as `onValueChange`
### Code changes
| Section | LOC change |
| --------------- | ---------- |
| Core code | +43 / -16 |
| Automated files | +2 / -0 |1 parent 18558fd commit 2632b5f
3 files changed
Lines changed: 45 additions & 16 deletions
File tree
- packages/tldraw
- src/lib/ui/components/StylePanel
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3149 | 3149 | | |
3150 | 3150 | | |
3151 | 3151 | | |
| 3152 | + | |
| 3153 | + | |
3152 | 3154 | | |
3153 | 3155 | | |
3154 | 3156 | | |
| |||
Lines changed: 3 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| |||
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
100 | | - | |
| 99 | + | |
101 | 100 | | |
102 | 101 | | |
103 | | - | |
104 | 102 | | |
105 | 103 | | |
106 | 104 | | |
107 | 105 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
| 106 | + | |
118 | 107 | | |
119 | | - | |
| 108 | + | |
120 | 109 | | |
121 | 110 | | |
122 | 111 | | |
| |||
Lines changed: 40 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
2 | 8 | | |
3 | 9 | | |
4 | 10 | | |
| |||
8 | 14 | | |
9 | 15 | | |
10 | 16 | | |
| 17 | + | |
11 | 18 | | |
12 | 19 | | |
13 | 20 | | |
| |||
28 | 35 | | |
29 | 36 | | |
30 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
31 | 45 | | |
32 | 46 | | |
33 | 47 | | |
34 | 48 | | |
35 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
36 | 52 | | |
37 | 53 | | |
38 | 54 | | |
| |||
41 | 57 | | |
42 | 58 | | |
43 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
44 | 81 | | |
45 | 82 | | |
46 | 83 | | |
47 | 84 | | |
48 | 85 | | |
49 | 86 | | |
50 | 87 | | |
| 88 | + | |
51 | 89 | | |
52 | 90 | | |
53 | 91 | | |
| |||
0 commit comments