Skip to content

Commit 2ca96c8

Browse files
fix(input): iOS Safari VoiceOver bug for date, time and color related types (#5207)
* fix: iOS Safari Voiceover input type date bug * Apply suggestion from @mfranzke * Apply suggestion from @mfranzke * Apply suggestion from @mfranzke * Apply suggestion from @mfranzke * Fix iOS Safari Voiceover bug for date and time inputs * fix: moved this code * auto update snapshots (#5208) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update input.lite.tsx * auto update snapshots (#5209) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Apply suggestion from @mfranzke * Apply suggestion from @mfranzke * Update .changeset/breezy-flies-burn.md * fix: angular build * auto update snapshots (#5210) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update input.lite.tsx * auto update snapshots (#5211) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * refactor: added missing types * Apply suggestions from code review * Apply suggestions from code review * Apply suggestions from code review * Update packages/components/src/components/input/input.lite.tsx --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent dc09ce6 commit 2ca96c8

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

.changeset/breezy-flies-burn.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@db-ux/core-components": patch
3+
"@db-ux/ngx-core-components": patch
4+
"@db-ux/react-core-components": patch
5+
"@db-ux/v-core-components": patch
6+
"@db-ux/wc-core-components": patch
7+
---
8+
9+
fix(input): iOS Safari VoiceOver bug for types `date`, `datetime-local`, `week`, `month` or `time`

packages/components/src/components/input/input.lite.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,22 @@ export default function DBInput(props: DBInputProps) {
159159
}))
160160
: _list) || []
161161
);
162+
},
163+
// iOS Safari VoiceOver input:is([type="date"], [type="datetime-local"], [type="time"], [type="week"], [type="month"], [type="color"]) hack
164+
// TODO: We could remove this one again, after https://bugs.webkit.org/show_bug.cgi?id=294649 (mentioned in https://github.com/facebook/react/issues/33541) has been resolved.
165+
isIOSSafari: (): boolean => {
166+
if (
167+
typeof window === 'undefined' ||
168+
typeof navigator === 'undefined'
169+
)
170+
return false;
171+
const ua = navigator.userAgent;
172+
// iOS detection
173+
const isIOS = /iP(ad|hone|od)/.test(ua);
174+
// Safari detection (not Chrome or Firefox on iOS)
175+
const isSafari =
176+
!!ua.match(/Safari/) && !ua.match(/CriOS|FxiOS|OPiOS|EdgiOS/);
177+
return isIOS && isSafari;
162178
}
163179
});
164180

@@ -260,6 +276,15 @@ export default function DBInput(props: DBInputProps) {
260276
}
261277
list={props.dataList && state._dataListId}
262278
aria-describedby={props.ariaDescribedBy ?? state._descByIds}
279+
// iOS Safari VoiceOver input:is([type="date"], [type="datetime-local"], [type="time"], [type="week"], [type="month"], [type="color"]) hack
280+
// TODO: We could remove this one again, after https://bugs.webkit.org/show_bug.cgi?id=294649 (mentioned in https://github.com/facebook/react/issues/33541) has been resolved.
281+
role={
282+
['datetime-local', 'date', 'time', 'week', 'month', 'color'].includes(
283+
props.type ?? ''
284+
) && state.isIOSSafari()
285+
? 'textbox'
286+
: undefined
287+
}
263288
/>
264289
<Show when={props.dataList}>
265290
<datalist id={state._dataListId}>

packages/components/src/components/input/model.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export type DBInputDefaultProps = {
100100
| 'search'
101101
| 'email'
102102
| 'url';
103-
/**
103+
/**
104104
* The size of the message infotext. Defaults to "small".
105105
*/
106106
messageSize?: SizeType;
@@ -133,6 +133,7 @@ export type DBInputProps = DBInputDefaultProps &
133133
export type DBInputDefaultState = {
134134
_dataListId?: string;
135135
getDataList: () => ValueLabelType[];
136+
isIOSSafari: () => boolean;
136137
};
137138

138139
export type DBInputState = DBInputDefaultState &

0 commit comments

Comments
 (0)