Merged in fix/SW-1970-focusable-input-ios-safari (pull request #1796)
fix(SW-1970): focusable inputs on safari ios Approved-by: Michael Zetterberg
This commit is contained in:
@@ -40,7 +40,7 @@ export default function AdditionalInfoForm({
|
||||
confirmationNumber,
|
||||
lastName,
|
||||
}).toString()
|
||||
document.cookie = `bv=${value}; Path=/; Max-Age=600; Secure; SameSite=Strict`
|
||||
document.cookie = `bv=${encodeURIComponent(value)}; Path=/; Max-Age=600; Secure; SameSite=Strict`
|
||||
router.refresh()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { cx } from "class-variance-authority"
|
||||
import { type ForwardedRef, forwardRef, useId } from "react"
|
||||
import {
|
||||
type ForwardedRef,
|
||||
forwardRef,
|
||||
useImperativeHandle,
|
||||
useRef,
|
||||
} from "react"
|
||||
import { Input as AriaInput, Label as AriaLabel } from "react-aria-components"
|
||||
|
||||
import Label from "@/components/TempDesignSystem/Form/Label"
|
||||
@@ -11,22 +16,31 @@ import type { AriaInputWithLabelProps } from "./input"
|
||||
|
||||
const AriaInputWithLabel = forwardRef(function AriaInputWithLabelComponent(
|
||||
{ label, ...props }: AriaInputWithLabelProps,
|
||||
ref: ForwardedRef<HTMLInputElement>
|
||||
forwardedRef: ForwardedRef<HTMLInputElement>
|
||||
) {
|
||||
const uniqueId = useId()
|
||||
const inputId = `${uniqueId}-${props.name}`
|
||||
const ref = useRef<HTMLInputElement>(null)
|
||||
|
||||
useImperativeHandle(forwardedRef, () => ref.current as HTMLInputElement)
|
||||
|
||||
return (
|
||||
<AriaLabel className={styles.container} htmlFor={inputId}>
|
||||
<AriaLabel
|
||||
className={styles.container}
|
||||
// fixes an issue with mobile devices being unable to
|
||||
// focus because the input height is 0
|
||||
onTouchStart={() => {
|
||||
if (ref.current) {
|
||||
ref.current.focus()
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Body asChild fontOnly>
|
||||
<AriaInput
|
||||
{...props}
|
||||
className={cx(styles.input, props.className)}
|
||||
ref={ref}
|
||||
id={inputId}
|
||||
/>
|
||||
</Body>
|
||||
<Label required={!!props.required}>{label}</Label>
|
||||
<Label required={props.required}>{label}</Label>
|
||||
</AriaLabel>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
line-height: 120%;
|
||||
text-align: left;
|
||||
transition: font-size 100ms ease;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
span.small {
|
||||
|
||||
Reference in New Issue
Block a user