@ultraviolet/ui 1.50.0 → 1.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _styled from '@emotion/styled/base';
|
|
2
2
|
import { Icon } from '@ultraviolet/icons';
|
|
3
|
+
import { useRef, useEffect } from 'react';
|
|
3
4
|
import { TextInputV2 } from '../TextInputV2/index.js';
|
|
4
5
|
import { useSelectInput } from './SelectInputProvider.js';
|
|
5
6
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
@@ -43,6 +44,7 @@ const SearchBarDropdown = ({
|
|
|
43
44
|
displayedOptions,
|
|
44
45
|
setSearchBarActive
|
|
45
46
|
}) => {
|
|
47
|
+
const searchInputRef = useRef(null);
|
|
46
48
|
const {
|
|
47
49
|
onChange,
|
|
48
50
|
onSearch,
|
|
@@ -97,6 +99,13 @@ const SearchBarDropdown = ({
|
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
};
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
// TODO: Remove me and use autoFocus when popup is fixed
|
|
104
|
+
// Explanation : Actually the component render at -999px -999px then it will be placed according to child position and it broke the autoFocus (scroll -999px to top)
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
searchInputRef.current?.focus();
|
|
107
|
+
}, 50);
|
|
108
|
+
}, []);
|
|
100
109
|
return jsx(StyledInput, {
|
|
101
110
|
value: searchInput,
|
|
102
111
|
onChange: event => handleChange(event),
|
|
@@ -110,9 +119,9 @@ const SearchBarDropdown = ({
|
|
|
110
119
|
sentiment: "neutral"
|
|
111
120
|
}),
|
|
112
121
|
onKeyDown: event => handleKeyDown(event.key, searchInput),
|
|
113
|
-
autoFocus: true,
|
|
114
122
|
size: "medium",
|
|
115
|
-
"aria-label": "search-bar"
|
|
123
|
+
"aria-label": "search-bar",
|
|
124
|
+
ref: searchInputRef
|
|
116
125
|
});
|
|
117
126
|
};
|
|
118
127
|
|