Skip to content

Commit 03a0739

Browse files
authored
Update form-datepicker.js
1 parent 71332e1 commit 03a0739

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

src/components/form-datepicker/form-datepicker.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -370,20 +370,20 @@ export const BFormDatepicker = /*#__PURE__*/ Vue.extend({
370370
render(h) {
371371
const size = this.size
372372
const state = this.state
373+
const visible = this.visible
374+
const isHovered = this.isHovered
375+
const hasFocus = this.hasFocus
373376
const localYMD = this.localYMD
374377
const disabled = this.disabled
375378
const readonly = this.readonly
379+
const required: this.required
380+
// These should move moved into computed props
376381
const idButton = this.safeId()
377382
const idLabel = this.safeId('_value_')
378383
const idMenu = this.safeId('_dialog_')
379384
const idWrapper = this.safeId('_b-form-date_')
380385

381-
let $button = h('div', { attrs: { 'aria-hidden': 'true' } }, [
382-
this.isHovered || this.hasFocus
383-
? h(BIconCalendarFill, { props: { scale: 1.25 } })
384-
: h(BIconCalendar, { props: { scale: 1.25 } })
385-
])
386-
$button = h(
386+
const $button = h(
387387
'button',
388388
{
389389
ref: 'toggle',
@@ -394,9 +394,9 @@ export const BFormDatepicker = /*#__PURE__*/ Vue.extend({
394394
type: 'button',
395395
disabled: disabled,
396396
'aria-haspopup': 'dialog',
397-
'aria-expanded': this.visible ? 'true' : 'false',
397+
'aria-expanded': visible ? 'true' : 'false',
398398
'aria-invalid': state === false ? 'true' : null,
399-
'aria-required': this.required ? 'true' : null
399+
'aria-required': required ? 'true' : null
400400
},
401401
on: {
402402
mousedown: this.onMousedown,
@@ -406,7 +406,12 @@ export const BFormDatepicker = /*#__PURE__*/ Vue.extend({
406406
'!blur': this.setFocus
407407
}
408408
},
409-
[$button]
409+
[
410+
h(isHovered || hasFocus ? BIconCalendarFill : BIconCalendar, {
411+
props: { scale: 1.25 },
412+
attrs: { 'aria-hidden': 'true' }
413+
})
414+
]
410415
)
411416

412417
// Label as a "fake" input
@@ -428,7 +433,7 @@ export const BFormDatepicker = /*#__PURE__*/ Vue.extend({
428433
dir: this.isRTL ? 'rtl' : 'ltr',
429434
lang: this.localLocale || null,
430435
'aria-invalid': state === false ? 'true' : null,
431-
'aria-required': this.required ? 'true' : null
436+
'aria-required': required ? 'true' : null
432437
},
433438
on: {
434439
// Disable bubbling of the click event to
@@ -440,7 +445,7 @@ export const BFormDatepicker = /*#__PURE__*/ Vue.extend({
440445
},
441446
[
442447
// Add the formatted value or placeholder
443-
localYMD ? this.formattedValue : this.placeholder || this.labelNoDateSelected,
448+
localYMD ? this.formattedValue : this.placeholder || this.labelNoDateSelected || '\u00A0',
444449
// Add an sr-only 'selected date' label if a date is selected
445450
localYMD ? h('span', { staticClass: 'sr-only' }, ` (${this.labelSelected}) `) : h()
446451
]
@@ -485,7 +490,7 @@ export const BFormDatepicker = /*#__PURE__*/ Vue.extend({
485490
h(
486491
BButton,
487492
{
488-
props: { size: 'sm', disabled: this.disabled, variant: this.closeButtonVariant },
493+
props: { size: 'sm', disabled: disabled, variant: this.closeButtonVariant },
489494
attrs: { 'aria-label': label || null },
490495
on: { click: this.onCloseButton }
491496
},
@@ -532,7 +537,7 @@ export const BFormDatepicker = /*#__PURE__*/ Vue.extend({
532537
ref: 'menu',
533538
staticClass: 'dropdown-menu p-2',
534539
class: {
535-
show: this.visible,
540+
show: visible,
536541
'dropdown-menu-right': this.right,
537542
'bg-dark': this.dark,
538543
'text-light': this.dark
@@ -569,8 +574,8 @@ export const BFormDatepicker = /*#__PURE__*/ Vue.extend({
569574
class: [
570575
this.directionClass,
571576
{
572-
show: this.visible,
573-
focus: this.hasFocus,
577+
show: visible,
578+
focus: hasFocus,
574579
[`form-control-${size}`]: !!size,
575580
'is-invalid': state === false,
576581
'is-valid': state === true
@@ -583,7 +588,7 @@ export const BFormDatepicker = /*#__PURE__*/ Vue.extend({
583588
'aria-readonly': readonly && !disabled,
584589
'aria-labelledby': idLabel,
585590
'aria-invalid': state === false ? 'true' : null,
586-
'aria-required': this.required ? 'true' : null,
591+
'aria-required': required ? 'true' : null,
587592
// We don't want the flex order to change here
588593
// So we always use 'ltr'
589594
dir: 'ltr'

0 commit comments

Comments
 (0)