Skip to content

Commit 16fbac7

Browse files
committed
feat(dateinput): Convert span to button
1 parent e15b48d commit 16fbac7

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

src/components/DateInput.vue

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
<div :class="{ 'input-group': bootstrapStyling }">
33
<slot name="beforeDateInput" />
44
<!-- Calendar Button -->
5-
<span
5+
<button
66
v-if="calendarButton"
77
class="vdp-datepicker__calendar-button"
8-
:class="{
9-
'input-group-prepend': bootstrapStyling,
10-
'calendar-btn-disabled': disabled,
11-
}"
8+
:class="{ 'btn input-group-prepend': bootstrapStyling }"
9+
:disabled="disabled"
10+
type="button"
1211
@click="toggle"
1312
>
1413
<span :class="{ 'input-group-text': bootstrapStyling }">
@@ -19,7 +18,7 @@
1918
</i>
2019
</slot>
2120
</span>
22-
</span>
21+
</button>
2322
<!-- Input -->
2423
<input
2524
:id="id"
@@ -46,11 +45,13 @@
4645
@keyup="parseTypedDate"
4746
/>
4847
<!-- Clear Button -->
49-
<span
48+
<button
5049
v-if="clearButton && selectedDate"
5150
class="vdp-datepicker__clear-button"
52-
:class="{ 'input-group-append': bootstrapStyling }"
53-
@click="clearDate()"
51+
:class="{ 'btn input-group-append': bootstrapStyling }"
52+
:disabled="disabled"
53+
type="button"
54+
@click="clearDate"
5455
>
5556
<span :class="{ 'input-group-text': bootstrapStyling }">
5657
<slot name="clearBtn">
@@ -59,7 +60,7 @@
5960
</i>
6061
</slot>
6162
</span>
62-
</span>
63+
</button>
6364
<slot name="afterDateInput" />
6465
</div>
6566
</template>

src/styles/style.scss

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
position: relative;
77
text-align: left;
88
box-sizing: border-box;
9-
10-
.calendar-btn-disabled {
11-
cursor: not-allowed;
12-
}
139
}
1410

1511
.vdp-datepicker__calendar {
@@ -36,6 +32,15 @@
3632
position: static;
3733
}
3834

35+
button {
36+
background: inherit;
37+
text-align: center;
38+
39+
&:disabled {
40+
color: #ddd;
41+
}
42+
}
43+
3944
header {
4045
display: flex;
4146
justify-content: space-between;
@@ -261,11 +266,11 @@
261266

262267
.vdp-datepicker__clear-button,
263268
.vdp-datepicker__calendar-button {
264-
cursor: pointer;
269+
border: none;
265270
font-style: normal;
266271

267-
&.disabled {
268-
color: #999;
269-
cursor: default;
272+
&.input-group-prepend,
273+
&.input-group-append {
274+
padding: 0;
270275
}
271276
}

test/unit/specs/DateInput/typedDates.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ describe('Datepicker mount', () => {
185185
})
186186

187187
const input = wrapper.find('input')
188-
const calendarButton = wrapper.find('span.vdp-datepicker__calendar-button')
188+
const calendarButton = wrapper.find('.vdp-datepicker__calendar-button')
189189

190190
await input.trigger('focus')
191191
expect(wrapper.vm.isOpen).toBeTruthy()

0 commit comments

Comments
 (0)