@dorsk/tsumikit 0.80.2 → 0.80.3

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.
@@ -239,13 +239,18 @@
239
239
  const pos = el.selectionStart ?? value.length;
240
240
  const id = ++reqId;
241
241
  const next = key ? await suggestSingle(schema, key, value) : await suggest(schema, value, pos);
242
- if (id !== reqId) return; // a newer keystroke won
242
+ if (id !== reqId || document.activeElement !== el) return;
243
243
  menu = next;
244
244
  active = 0;
245
245
  keyboardNavigation = false;
246
246
  open = !!next && next.items.length > 0;
247
247
  }
248
248
 
249
+ function close() {
250
+ ++reqId;
251
+ open = false;
252
+ }
253
+
249
254
  function accept(i: number) {
250
255
  if (!menu || !el) return;
251
256
  const s = menu.items[i];
@@ -269,7 +274,7 @@
269
274
  el.focus();
270
275
  el.setSelectionRange(caret, caret);
271
276
  if (s.advance) refresh();
272
- else open = false;
277
+ else close();
273
278
  });
274
279
  }
275
280
 
@@ -282,7 +287,7 @@
282
287
  const exit = closingQuoteExit(value, pos);
283
288
  if (exit !== null) {
284
289
  e.preventDefault();
285
- open = false;
290
+ close();
286
291
  setCaret(exit);
287
292
  return;
288
293
  }
@@ -299,6 +304,7 @@
299
304
  }
300
305
  if (!open || !menu) {
301
306
  if (e.key === 'Enter') submit();
307
+ else if (e.key === 'Escape') close();
302
308
  return;
303
309
  }
304
310
  switch (e.key) {
@@ -319,13 +325,13 @@
319
325
  break;
320
326
  case 'Escape':
321
327
  e.preventDefault();
322
- open = false;
328
+ close();
323
329
  break;
324
330
  }
325
331
  }
326
332
 
327
333
  function submit() {
328
- open = false;
334
+ close();
329
335
  onsubmit?.(value);
330
336
  }
331
337
 
@@ -399,7 +405,9 @@
399
405
  }}
400
406
  onblur={() => {
401
407
  focused = false;
402
- setTimeout(() => (open = false), 120);
408
+ setTimeout(() => {
409
+ if (document.activeElement !== el) close();
410
+ }, 120);
403
411
  }}
404
412
  {onkeydown}
405
413
  />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dorsk/tsumikit",
3
- "version": "0.80.2",
3
+ "version": "0.80.3",
4
4
  "description": "Minimal, dependency-free Svelte 5 + pure-CSS UI kit. Token-driven atoms, molecules & layouts with theming out of the box.",
5
5
  "type": "module",
6
6
  "license": "MIT",