@classic-homes/theme-svelte 1.19.0 → 1.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -221,3 +221,20 @@ describe('StudioCanvasItem', () => {
221
221
  expect(onInsert).toHaveBeenCalled();
222
222
  });
223
223
  });
224
+ describe('StudioCanvasItem quick actions', () => {
225
+ it('does not select the item when focus lands on its "+" (a closing dialog returns it there)', () => {
226
+ const onSelect = vi.fn();
227
+ const el = render(StudioCanvasItem, {
228
+ label: 'Question 1',
229
+ onSelect,
230
+ onInsert: () => { },
231
+ children: html('<p>Body</p>'),
232
+ });
233
+ el.querySelector('button[aria-label="Add below Question 1"]').focus();
234
+ flushSync();
235
+ expect(onSelect).not.toHaveBeenCalled();
236
+ el.querySelector('button').focus(); // the "Edit Question 1" button
237
+ flushSync();
238
+ expect(onSelect).toHaveBeenCalledTimes(1);
239
+ });
240
+ });
@@ -45,6 +45,12 @@
45
45
  const studio = getStudioContext();
46
46
  let element: HTMLDivElement | undefined = $state();
47
47
 
48
+ // Quick actions (toolbar, "+") act on the item without selecting it. A
49
+ // dialog they open (the insert palette) returns focus to them on close;
50
+ // treating that focus as "select me" would undo the dialog's own selection.
51
+ const inQuickAction = (target: EventTarget | null) =>
52
+ !!(target as Element | null)?.closest?.('[data-studio-quick-action]');
53
+
48
54
  function select(reveal: boolean) {
49
55
  if (!selected) onSelect?.();
50
56
  if (reveal) studio?.revealInspector();
@@ -76,8 +82,10 @@
76
82
  invalid && 'outline-dashed outline-2 -outline-offset-2 outline-warning/70',
77
83
  className
78
84
  )}
79
- onclickcapture={(e) => select(!(e.target as Element).closest?.('[data-studio-quick-action]'))}
80
- onfocusin={() => select(false)}
85
+ onclickcapture={(e) => select(!inQuickAction(e.target))}
86
+ onfocusin={(e) => {
87
+ if (!inQuickAction(e.target)) select(false);
88
+ }}
81
89
  >
82
90
  {#if !selected}
83
91
  <!-- Keyboard way in for items with no focusable content of their own -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/theme-svelte",
3
- "version": "1.19.0",
3
+ "version": "1.19.1",
4
4
  "description": "Svelte components for the Classic theme system",
5
5
  "type": "module",
6
6
  "svelte": "./dist/lib/index.js",