[searchpanel]검색어 남아있을시 포커스 첫번째로 옮겼을때 키패드 사라지지않도록수정
This commit is contained in:
@@ -66,6 +66,8 @@ export default function SearchPanel({ panelInfo, isOnTop, spotlightId }) {
|
||||
const [searchQuery, setSearchQuery] = useState(
|
||||
panelInfo.searchVal ? panelInfo.searchVal : null
|
||||
);
|
||||
const [position, setPosition] = useState(null);
|
||||
|
||||
let searchQueryRef = usePrevious(searchQuery);
|
||||
let isOnTopRef = usePrevious(isOnTop);
|
||||
|
||||
@@ -192,9 +194,25 @@ export default function SearchPanel({ panelInfo, isOnTop, spotlightId }) {
|
||||
if (!isOnTopRef.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.key === "Enter") {
|
||||
handleSearchSubmit(searchQuery);
|
||||
}
|
||||
|
||||
if (position === 0) {
|
||||
if (e.key === "Left" || e.key === "ArrowLeft") {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const cursorPosition = () => {
|
||||
const input = document.querySelector(
|
||||
`[data-spotlight-id="input-field-box"] > input`
|
||||
);
|
||||
if (input) {
|
||||
setPosition(input.selectionStart);
|
||||
}
|
||||
};
|
||||
|
||||
const onCancel = useCallback(() => {
|
||||
@@ -277,6 +295,7 @@ export default function SearchPanel({ panelInfo, isOnTop, spotlightId }) {
|
||||
onChange={handleSearchChange}
|
||||
onIconClick={() => handleSearchSubmit(searchQuery)}
|
||||
onKeyDown={handleKeydown}
|
||||
onKeyUp={cursorPosition}
|
||||
forcedSpotlight="first-keyword-button"
|
||||
spotlightId={"search-input-box"}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user