Fix Bug 67194 - Mobile. Fixed input focus for iPad

This commit is contained in:
Nikita Gopienko 2024-04-08 14:37:46 +03:00
parent 3d7e841cf0
commit 0a66045569
3 changed files with 20 additions and 0 deletions

View File

@ -28,6 +28,8 @@ import React from "react";
import { useTheme } from "styled-components";
import { useTranslation } from "react-i18next";
import { isTablet, isIOS } from "react-device-detect";
import { DeviceType, FilterGroups } from "../../enums";
import { TViewSelectorOption, ViewSelector } from "../view-selector";
@ -175,6 +177,19 @@ const FilterInput = React.memo(
[selectedItems, removeSelectedItem],
);
const onInputFocus = (e: React.FocusEvent<HTMLInputElement>) => {
if (isTablet && isIOS) {
const scrollEvent = () => {
e.preventDefault();
e.stopPropagation();
window.scrollTo(0, 0);
window.onscroll = () => {};
};
window.onscroll = scrollEvent;
}
};
React.useEffect(() => {
return () => {
mountRef.current = false;
@ -191,6 +206,7 @@ const FilterInput = React.memo(
onClearSearch={onClearSearch}
id="filter_search-input"
size={InputSize.base}
onFocus={onInputFocus}
/>
<FilterButton
id="filter-button"

View File

@ -53,6 +53,7 @@ const SearchInput = ({
name,
isDisabled = false,
placeholder,
onFocus,
children,
}: SearchInputProps) => {
const timerId = React.useRef<null | ReturnType<typeof setTimeout>>(null);
@ -162,6 +163,7 @@ const SearchInput = ({
value={inputValue}
placeholder={placeholder}
onChange={onInputChange}
onFocus={onFocus}
>
{children}
</InputBlock>

View File

@ -62,4 +62,6 @@ export interface SearchInputProps {
children?: React.ReactNode;
/** Accepts css style */
style?: React.CSSProperties;
/** The callback function that is called when the field is focused */
onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;
}