|
45 | 45 | :readonly="configuration.readonly" |
46 | 46 | :placeholder="configuration.placeholder" |
47 | 47 | v-bind="configuration.userInputAttributes" |
| 48 | + data-datepicker-focusable |
48 | 49 | @input="userInputHandler" |
49 | 50 | @focus="focusHandler" |
50 | 51 | @blur="blurHandler" |
@@ -310,7 +311,6 @@ export default defineComponent({ |
310 | 311 | // - Replace svg icons with icon component |
311 | 312 | // - The click handler depnds of shown consider the case when using inline |
312 | 313 | // - Consider using an undefined default value for togglin and, in cases like multiple or range keep the dropdown opened by default |
313 | | - // - In multiple add an ok button |
314 | 314 | // - Add a clear button |
315 | 315 | const { configuration, attributes } = useConfigurationWithClassesList<TDatepickerOptions>(TDatepickerConfig, TDatepickerClassesKeys); |
316 | 316 | const locale = useDateLocale({ configuration }); |
@@ -435,13 +435,22 @@ export default defineComponent({ |
435 | 435 | }; |
436 | 436 |
|
437 | 437 | // If the date field is blurred (date clicked for example) we should focus |
438 | | - // the field again |
439 | | - // @TODO: Consider the case when other elements should keep the focus |
440 | | - // like the eventual time picker |
441 | | - const blurOnChildHandler = (e: Event) => { |
| 438 | + // the field again unless is a child element |
| 439 | + const blurOnChildHandler = (e: FocusEvent) => { |
442 | 440 | const target = e.target as HTMLButtonElement | HTMLInputElement; |
443 | 441 |
|
444 | | - target.focus(); |
| 442 | + const relatedTarget = e.relatedTarget as HTMLElement | EventTarget; |
| 443 | + const relatedTargetDataset: Data | undefined = relatedTarget instanceof HTMLElement |
| 444 | + ? relatedTarget.dataset |
| 445 | + : undefined; |
| 446 | + |
| 447 | + if ( |
| 448 | + target.dataset.datepickerFocusable !== undefined |
| 449 | + && relatedTargetDataset |
| 450 | + && relatedTargetDataset.datepickerFocusable === undefined |
| 451 | + ) { |
| 452 | + target.focus(); |
| 453 | + } |
445 | 454 | }; |
446 | 455 |
|
447 | 456 | const keyboardNavigationHandler = (e: KeyboardEvent) => { |
|
0 commit comments