@momentum-design/components 0.133.31 → 0.133.32

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.
@@ -198,6 +198,11 @@ declare class TimePicker extends TimePicker_base implements AssociatedFormContro
198
198
  * @internal
199
199
  */
200
200
  private focusMenuItemOnOpen;
201
+ /**
202
+ * Gets the option index that should receive focus when the menu opens.
203
+ * @internal
204
+ */
205
+ private getMenuItemFocusIndex;
201
206
  /**
202
207
  * Focuses the menu item at the current focusedOptionIndex.
203
208
  * @internal
@@ -243,11 +248,10 @@ declare class TimePicker extends TimePicker_base implements AssociatedFormContro
243
248
  */
244
249
  private handleDropdownClick;
245
250
  /**
246
- * Handles clicking on the spinbutton area (not the dropdown button).
247
- * Focuses the nearest spinbutton.
251
+ * Handles clicking on the base container.
248
252
  * @internal
249
253
  */
250
- private handleSpinbuttonAreaClick;
254
+ private handleBaseContainerClick;
251
255
  /**
252
256
  * Handles keydown on the base container (when popover is closed).
253
257
  * @internal
@@ -218,16 +218,25 @@ class TimePicker extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)
218
218
  * @internal
219
219
  */
220
220
  focusMenuItemOnOpen() {
221
- const options = this.getTimeOptions();
222
- const currentValue = this.internalToValue();
223
- const selectedIndex = options.findIndex(opt => opt.value === currentValue);
224
- this.focusedOptionIndex = selectedIndex >= 0 ? selectedIndex : 0;
221
+ this.focusedOptionIndex = this.getMenuItemFocusIndex();
225
222
  this.updateComplete
226
223
  .then(() => {
227
- this.focusCurrentMenuItem();
224
+ window.requestAnimationFrame(() => {
225
+ this.focusCurrentMenuItem();
226
+ });
228
227
  })
229
228
  .catch(() => { });
230
229
  }
230
+ /**
231
+ * Gets the option index that should receive focus when the menu opens.
232
+ * @internal
233
+ */
234
+ getMenuItemFocusIndex() {
235
+ const options = this.getTimeOptions();
236
+ const currentValue = this.internalToValue();
237
+ const selectedIndex = options.findIndex(opt => opt.value === currentValue);
238
+ return selectedIndex >= 0 ? selectedIndex : 0;
239
+ }
231
240
  /**
232
241
  * Focuses the menu item at the current focusedOptionIndex.
233
242
  * @internal
@@ -238,8 +247,10 @@ class TimePicker extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)
238
247
  if (!listbox)
239
248
  return;
240
249
  const items = listbox.querySelectorAll('mdc-option');
241
- if (items[this.focusedOptionIndex]) {
242
- items[this.focusedOptionIndex].focus();
250
+ const item = items[this.focusedOptionIndex];
251
+ if (item) {
252
+ item.focus({ preventScroll: true });
253
+ item.scrollIntoView({ block: 'nearest' });
243
254
  }
244
255
  }
245
256
  /** @internal */
@@ -410,21 +421,27 @@ class TimePicker extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)
410
421
  event.stopPropagation();
411
422
  }
412
423
  /**
413
- * Handles clicking on the spinbutton area (not the dropdown button).
414
- * Focuses the nearest spinbutton.
424
+ * Handles clicking on the base container.
415
425
  * @internal
416
426
  */
417
- handleSpinbuttonAreaClick(event) {
418
- var _a, _b;
427
+ handleBaseContainerClick(event) {
428
+ var _a, _b, _c;
419
429
  if (this.disabled || this.softDisabled || this.readonly)
420
430
  return;
421
431
  const target = event.target;
422
432
  // If clicking on a spinbutton itself, let it handle focus
423
433
  if (target.getAttribute('role') === 'spinbutton')
424
434
  return;
435
+ // If clicking the non-editable blank area, treat it like the dropdown button.
436
+ if (target.getAttribute('part') === 'base-container' || target.getAttribute('part') === 'spinbutton-group') {
437
+ this.displayPopover = !this.displayPopover;
438
+ (_a = this.dropdownButton) === null || _a === void 0 ? void 0 : _a.focus();
439
+ event.stopPropagation();
440
+ return;
441
+ }
425
442
  // Otherwise focus the hours spinbutton
426
- (_a = this.hoursInput) === null || _a === void 0 ? void 0 : _a.focus();
427
- (_b = this.hoursInput) === null || _b === void 0 ? void 0 : _b.select();
443
+ (_b = this.hoursInput) === null || _b === void 0 ? void 0 : _b.focus();
444
+ (_c = this.hoursInput) === null || _c === void 0 ? void 0 : _c.select();
428
445
  }
429
446
  /**
430
447
  * Handles keydown on the base container (when popover is closed).
@@ -771,7 +788,7 @@ class TimePicker extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)
771
788
  id="${TRIGGER_ID}"
772
789
  part="base-container"
773
790
  class="mdc-focus-ring"
774
- @click="${this.handleSpinbuttonAreaClick}"
791
+ @click="${this.handleBaseContainerClick}"
775
792
  @keydown="${this.handleBaseKeydown}"
776
793
  >
777
794
  <div part="spinbutton-group">
@@ -868,6 +885,7 @@ class TimePicker extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)
868
885
  hide-on-escape
869
886
  focus-back-to-trigger
870
887
  focus-trap
888
+ element-index-to-receive-focus="${this.getMenuItemFocusIndex()}"
871
889
  disable-aria-expanded
872
890
  size
873
891
  ?disable-flip="${this.disableFlip}"
@@ -9,6 +9,7 @@ const styles = css `
9
9
  --mdc-timepicker-width: fit-content;
10
10
  --mdc-timepicker-listbox-width: 100%;
11
11
  --mdc-timepicker-listbox-height: 15rem;
12
+ --mdc-timepicker-option-scroll-margin: 0.25rem;
12
13
 
13
14
  display: flex;
14
15
  flex-direction: column;
@@ -150,6 +151,10 @@ const styles = css `
150
151
  max-height: var(--mdc-popover-internal-available-height);
151
152
  }
152
153
 
154
+ :host mdc-option {
155
+ scroll-margin-block: var(--mdc-timepicker-option-scroll-margin);
156
+ }
157
+
153
158
  /* Help text border colors */
154
159
  :host([help-text-type='success'])::part(base-container),
155
160
  :host([help-text-type='warning'])::part(base-container),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@momentum-design/components",
3
3
  "packageManager": "yarn@3.2.4",
4
- "version": "0.133.31",
4
+ "version": "0.133.32",
5
5
  "engines": {
6
6
  "node": ">=20.0.0",
7
7
  "npm": ">=8.0.0"