Skip to content

Commit c2dc849

Browse files
authored
fix: issue for input calendar focus (#4202)
1 parent e5f5694 commit c2dc849

File tree

9 files changed

+78
-52
lines changed

9 files changed

+78
-52
lines changed
Loading
-542 Bytes
Loading
-2.04 KB
Loading

__snapshots__/input/showcase/firefox/should-have-same-aria-snapshot/DBInput-should-have-same-aria-snapshot.yaml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,18 @@
117117
- text: Label
118118
- textbox "Label"
119119
- status
120-
- text: calendar" / " Label
120+
- text: Label
121121
- textbox "Label"
122122
- status
123-
- text: calendar" / " Label
123+
- text: Label
124124
- textbox "Label"
125125
- status
126-
- text: calendar" / " Label
126+
- text: Label
127127
- textbox "Label"
128128
- status
129-
- text: clock" / " Label
129+
- text: Label
130130
- textbox "Label"
131131
- status
132-
- text: calendar" / "
133132
- link "Example Floating Label arrow_up_right\" / \""
134133
- text: Label
135134
- textbox "Label"
@@ -165,19 +164,19 @@
165164
- text: Label
166165
- textbox "Label"
167166
- status
168-
- text: calendar" / " Label
167+
- text: Label
169168
- textbox "Label"
170169
- status
171-
- text: calendar" / " Label
170+
- text: Label
172171
- textbox "Label"
173172
- status
174-
- text: calendar" / " Label
173+
- text: Label
175174
- textbox "Label"
176175
- status
177-
- text: clock" / " Label
176+
- text: Label
178177
- textbox "Label"
179178
- status
180-
- text: calendar" / " Label
179+
- text: Label
181180
- combobox "Label"
182181
- status
183182
- text: chevron_down" / " Label
-447 Bytes
Loading

__snapshots__/input/showcase/mobile-safari/should-have-same-aria-snapshot/DBInput-should-have-same-aria-snapshot.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,19 @@
118118
- text: Label
119119
- textbox "Label"
120120
- status
121-
- text: calendar" / " Label
121+
- text: "\" / \" Label"
122122
- textbox "Label"
123123
- status
124-
- text: calendar" / " Label
124+
- text: "\" / \" Label"
125125
- textbox "Label"
126126
- status
127-
- text: calendar" / " Label
127+
- text: "\" / \" Label"
128128
- textbox "Label"
129129
- status
130-
- text: clock" / " Label
130+
- text: "\" / \" Label"
131131
- textbox "Label"
132132
- status
133-
- text: calendar" / "
133+
- text: "\" / \""
134134
- link "Example Floating Label arrow_up_right\" / \""
135135
- text: Label
136136
- textbox "Label"
@@ -166,19 +166,19 @@
166166
- text: Label
167167
- textbox "Label"
168168
- status
169-
- text: calendar" / " Label
169+
- text: "\" / \" Label"
170170
- textbox "Label"
171171
- status
172-
- text: calendar" / " Label
172+
- text: "\" / \" Label"
173173
- textbox "Label"
174174
- status
175-
- text: calendar" / " Label
175+
- text: "\" / \" Label"
176176
- textbox "Label"
177177
- status
178-
- text: clock" / " Label
178+
- text: "\" / \" Label"
179179
- textbox "Label"
180180
- status
181-
- text: calendar" / " Label
181+
- text: "\" / \" Label"
182182
- combobox "Label"
183183
- status
184184
- text: chevron_down" / " Label

__snapshots__/input/showcase/webkit/should-have-same-aria-snapshot/DBInput-should-have-same-aria-snapshot.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,19 @@
118118
- text: Label
119119
- textbox "Label"
120120
- status
121-
- text: calendar" / " Label
121+
- text: "\" / \" Label"
122122
- textbox "Label"
123123
- status
124-
- text: calendar" / " Label
124+
- text: "\" / \" Label"
125125
- textbox "Label"
126126
- status
127-
- text: calendar" / " Label
127+
- text: "\" / \" Label"
128128
- textbox "Label"
129129
- status
130-
- text: clock" / " Label
130+
- text: "\" / \" Label"
131131
- textbox "Label"
132132
- status
133-
- text: calendar" / "
133+
- text: "\" / \""
134134
- link "Example Floating Label arrow_up_right\" / \""
135135
- text: Label
136136
- textbox "Label"
@@ -166,19 +166,19 @@
166166
- text: Label
167167
- textbox "Label"
168168
- status
169-
- text: calendar" / " Label
169+
- text: "\" / \" Label"
170170
- textbox "Label"
171171
- status
172-
- text: calendar" / " Label
172+
- text: "\" / \" Label"
173173
- textbox "Label"
174174
- status
175-
- text: calendar" / " Label
175+
- text: "\" / \" Label"
176176
- textbox "Label"
177177
- status
178-
- text: clock" / " Label
178+
- text: "\" / \" Label"
179179
- textbox "Label"
180180
- status
181-
- text: calendar" / " Label
181+
- text: "\" / \" Label"
182182
- combobox "Label"
183183
- status
184184
- text: chevron_down" / " Label

packages/components/src/components/input/input.scss

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,19 @@ $icon-padding: calc(
6767
}
6868
}
6969

70-
&:has(input[type="date"]),
71-
&:has(input[type="week"]),
72-
&:has(input[type="datetime-local"]),
73-
&:has(input[type="month"]) {
74-
@include icons.set-icon("calendar", "after");
75-
}
70+
// This @supports should exclude Mozilla Firefox
71+
// TODO: Reevaluate after Mozilla is supporting week and month input types
72+
@supports selector(::-webkit-calendar-picker-indicator) {
73+
&:has(input[type="date"]),
74+
&:has(input[type="week"]),
75+
&:has(input[type="datetime-local"]),
76+
&:has(input[type="month"]) {
77+
@include icons.set-icon("calendar", "after");
78+
}
7679

77-
&:has(input[type="time"]) {
78-
@include icons.set-icon("clock", "after");
80+
&:has(input[type="time"]) {
81+
@include icons.set-icon("clock", "after");
82+
}
7983
}
8084

8185
&:has(input[type="file"]) {
@@ -105,16 +109,35 @@ $icon-padding: calc(
105109
}
106110
}
107111

112+
&[data-variant="floating"] {
113+
input {
114+
&::-webkit-calendar-picker-indicator,
115+
&::-webkit-search-cancel-button {
116+
/* stylelint-disable-next-line db-ux/use-spacings */
117+
margin-block-end: var(--db-base-body-icon-font-size-2xs);
118+
}
119+
}
120+
}
121+
108122
input {
109123
position: relative;
110124

111125
&::-webkit-calendar-picker-indicator,
112126
&::-webkit-search-cancel-button {
127+
@extend %db-overwrite-font-size-sm;
128+
113129
background-image: none;
114130
inline-size: icons.$default-icon-font-size;
115131
block-size: icons.$default-icon-font-size;
116132
padding: 0;
117133
cursor: pointer;
134+
/* stylelint-disable-next-line db-ux/use-spacings */
135+
margin-block-start: variables.$db-border-width-3xs;
136+
border-radius: variables.$db-border-radius-xs;
137+
138+
&:focus-visible {
139+
@include helpers.get-focus-placeholder;
140+
}
118141
}
119142

120143
&::-webkit-search-cancel-button {
Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
@use "../variables";
22
@use "../colors";
33

4+
@mixin get-focus-placeholder {
5+
outline: #{variables.$db-border-width-2xs} solid
6+
var(
7+
--db-focus-outline-color,
8+
#{colors.$db-informational-on-bg-basic-emphasis-70-default}
9+
);
10+
outline-offset: variables.$db-border-width-xs;
11+
box-shadow: 0 0 0 #{variables.$db-border-width-xs}
12+
var(--db-focus-box-shadow-bg-color, transparent);
13+
14+
@media screen and (prefers-reduced-motion: no-preference) {
15+
transition:
16+
outline #{variables.$db-transition-duration-extra-fast},
17+
box-shadow #{variables.$db-transition-duration-extra-fast};
18+
}
19+
}
20+
421
%focus-placeholder {
522
&:not([data-disable-focus="true"]) {
6-
outline: #{variables.$db-border-width-2xs} solid
7-
var(
8-
--db-focus-outline-color,
9-
#{colors.$db-informational-on-bg-basic-emphasis-70-default}
10-
);
11-
outline-offset: variables.$db-border-width-xs;
12-
box-shadow: 0 0 0 #{variables.$db-border-width-xs}
13-
var(--db-focus-box-shadow-bg-color, transparent);
23+
@include get-focus-placeholder;
1424

1525
&:not([type="radio"], [role="switch"]) {
1626
border-radius: variables.$db-border-radius-xs;
1727
}
18-
19-
@media screen and (prefers-reduced-motion: no-preference) {
20-
transition:
21-
outline #{variables.$db-transition-duration-extra-fast},
22-
box-shadow #{variables.$db-transition-duration-extra-fast};
23-
}
2428
}
2529
}

0 commit comments

Comments
 (0)