@kouji-ui/core 0.6.2 → 0.6.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.
@@ -2438,10 +2438,22 @@ class KjListNavigator {
2438
2438
  this.moveBy(-this.kjPageSize());
2439
2439
  return;
2440
2440
  case 'Enter':
2441
- case ' ':
2442
2441
  // Only preventDefault when we actually activate. Lets consumers
2443
- // (e.g. combobox free-text Enter) fall through when nothing is
2444
- // active, and lets Space type a literal space in a combobox input.
2442
+ // (e.g. combobox free-text Enter) fall through when nothing is active.
2443
+ if (this.activeItem()) {
2444
+ e.preventDefault();
2445
+ this.activateCurrent();
2446
+ }
2447
+ return;
2448
+ case ' ':
2449
+ // Space activates a LIST — but in a text field it is a character the
2450
+ // user is typing, and the field owns it. A command palette highlights
2451
+ // a row for every query, so treating Space as activation there made
2452
+ // multi-word queries impossible: the space ran the highlighted command
2453
+ // instead of reaching the input. Enter remains the activation key from
2454
+ // a text field.
2455
+ if (isTextEntry(e.target))
2456
+ return;
2445
2457
  if (this.activeItem()) {
2446
2458
  e.preventDefault();
2447
2459
  this.activateCurrent();
@@ -2488,6 +2500,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
2488
2500
  },
2489
2501
  }]
2490
2502
  }], ctorParameters: () => [], propDecorators: { kjOrientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "kjOrientation", required: false }] }], kjWrap: [{ type: i0.Input, args: [{ isSignal: true, alias: "kjWrap", required: false }] }], kjPageSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "kjPageSize", required: false }] }], kjActivateOnHover: [{ type: i0.Input, args: [{ isSignal: true, alias: "kjActivateOnHover", required: false }] }], kjFocusMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "kjFocusMode", required: false }] }], kjActiveChange: [{ type: i0.Output, args: ["kjActiveChange"] }] } });
2503
+ /** Types of `<input>` that hold text the user types (Space is a character). */
2504
+ const NON_TEXT_INPUT_TYPES = new Set([
2505
+ 'button',
2506
+ 'checkbox',
2507
+ 'color',
2508
+ 'file',
2509
+ 'image',
2510
+ 'radio',
2511
+ 'range',
2512
+ 'reset',
2513
+ 'submit',
2514
+ ]);
2515
+ /** Whether a key event landed in a field where Space types a character. */
2516
+ function isTextEntry(target) {
2517
+ const el = target;
2518
+ if (!el || typeof el.tagName !== 'string')
2519
+ return false;
2520
+ if (el.isContentEditable)
2521
+ return true;
2522
+ if (el.tagName === 'TEXTAREA')
2523
+ return true;
2524
+ if (el.tagName !== 'INPUT')
2525
+ return false;
2526
+ const type = el.type?.toLowerCase() ?? 'text';
2527
+ return !NON_TEXT_INPUT_TYPES.has(type);
2528
+ }
2491
2529
 
2492
2530
  // packages/core/src/primitives/list/selection.ts
2493
2531
  /**