Skip to content

Commit 145e145

Browse files
committed
fix: blur on drawer open
1 parent 7aa2e61 commit 145e145

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/components/Search/Search.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface SearchProps {
1515
className?: string;
1616
debounce?: number;
1717
placeholder?: string;
18+
inputRef?: React.RefObject<HTMLInputElement>;
1819
}
1920

2021
export const Search = ({
@@ -24,6 +25,7 @@ export const Search = ({
2425
className,
2526
debounce = 200,
2627
placeholder,
28+
inputRef,
2729
}: SearchProps) => {
2830
const [searchValue, setSearchValue] = React.useState<string>(value);
2931

@@ -52,6 +54,7 @@ export const Search = ({
5254
<TextInput
5355
hasClear
5456
autoFocus
57+
controlRef={inputRef}
5558
style={{width}}
5659
className={b(null, className)}
5760
placeholder={placeholder}

src/containers/Tenant/Diagnostics/TopQueries/RunningQueriesData.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ export const RunningQueriesData = ({
9999
[setSelectedRow],
100100
);
101101

102+
const inputRef = React.useRef<HTMLInputElement>(null);
103+
104+
React.useEffect(() => {
105+
if (isDrawerVisible) {
106+
inputRef.current?.blur();
107+
}
108+
}, [isDrawerVisible]);
109+
102110
return (
103111
<Drawer.ItemWrapper
104112
isDrawerVisible={isDrawerVisible}
@@ -117,6 +125,7 @@ export const RunningQueriesData = ({
117125
onChange={handleTextSearchUpdate}
118126
placeholder={i18n('filter.text.placeholder')}
119127
className={b('search')}
128+
inputRef={inputRef}
120129
/>
121130
<TableColumnSetup
122131
popupWidth={200}

src/containers/Tenant/Diagnostics/TopQueries/TopQueriesData.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ export const TopQueriesData = ({
127127
[setSelectedRow],
128128
);
129129

130+
const inputRef = React.useRef<HTMLInputElement>(null);
131+
132+
React.useEffect(() => {
133+
if (isDrawerVisible) {
134+
inputRef.current?.blur();
135+
}
136+
}, [isDrawerVisible]);
137+
130138
return (
131139
<Drawer.ItemWrapper
132140
isDrawerVisible={isDrawerVisible}
@@ -153,6 +161,7 @@ export const TopQueriesData = ({
153161
/>
154162
<Search
155163
value={filters.text}
164+
inputRef={inputRef}
156165
onChange={handleTextSearchUpdate}
157166
placeholder={i18n('filter.text.placeholder')}
158167
className={b('search')}

0 commit comments

Comments
 (0)