diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-11-25 11:47:33 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-11-25 11:47:33 +0100 |
| commit | d5f216e2d99071958d9d635e9639971255ca61ef (patch) | |
| tree | e4706745c8531c64ef35b47609917e1709375f54 | |
| parent | adf299a1be11c9c8443de2d88899b686d1c31c49 (diff) | |
| download | mullvadvpn-d5f216e2d99071958d9d635e9639971255ca61ef.tar.xz mullvadvpn-d5f216e2d99071958d9d635e9639971255ca61ef.zip | |
Add auto focus to search bar
| -rw-r--r-- | gui/src/renderer/components/SearchBar.tsx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gui/src/renderer/components/SearchBar.tsx b/gui/src/renderer/components/SearchBar.tsx index a659f6130f..c70e5c3de1 100644 --- a/gui/src/renderer/components/SearchBar.tsx +++ b/gui/src/renderer/components/SearchBar.tsx @@ -1,4 +1,4 @@ -import { useCallback, useRef } from 'react'; +import { useCallback, useEffect, useRef } from 'react'; import styled from 'styled-components'; import { colors } from '../../config.json'; @@ -68,6 +68,7 @@ interface ISearchBarProps { searchTerm: string; onSearch: (searchTerm: string) => void; className?: string; + disableAutoFocus?: boolean; } export default function SearchBar(props: ISearchBarProps) { @@ -86,6 +87,12 @@ export default function SearchBar(props: ISearchBarProps) { inputRef.current?.blur(); }, [props.onSearch]); + useEffect(() => { + if (!props.disableAutoFocus) { + inputRef.current?.focus(); + } + }, []); + return ( <StyledSearchContainer className={props.className}> <StyledSearchInput |
