0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-04-14 23:11:31 -05:00

fix(ui): set tabIndex -1 for hidden countryCode (#3842)

setTabIndex -1 for hidden countryCode
This commit is contained in:
simeng-li 2023-05-16 09:07:36 +08:00 committed by GitHub
parent 0023dfe38a
commit baa16b0bb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -48,7 +48,7 @@ const AnimatedPrefix = ({ children, isVisible }: Props) => {
return (
<animated.div className={styles.prefix} style={animation} data-testid="prefix">
{cloneElement(children, { ref: elementRef })}
{cloneElement(children, { ref: elementRef, isVisible })}
</animated.div>
);
};

View file

@ -14,11 +14,12 @@ type Props = {
className?: string;
value?: string;
inputRef?: Nullable<HTMLInputElement>;
isVisible?: boolean;
onChange?: (value: string) => void;
};
const CountryCodeSelector = (
{ className, value, inputRef, onChange }: Props,
{ className, value, inputRef, isVisible = true, onChange }: Props,
ref: ForwardedRef<HTMLDivElement>
) => {
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
@ -41,7 +42,7 @@ const CountryCodeSelector = (
ref={ref}
className={classNames(styles.countryCodeSelector, className)}
role="button"
tabIndex={0}
tabIndex={isVisible ? 0 : -1}
onClick={showDropDown}
onKeyDown={onKeyDownHandler({
Enter: showDropDown,