Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: select main input on show option #630

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const schema = {
firstStart: { type: 'boolean', default: true },
developerMode: { type: 'boolean', default: false },
cleanOnHide: { type: 'boolean', default: true },
selectOnShow: { type: 'boolean', default: false },
hideOnBlur: { type: 'boolean', default: true },
skipDonateDialog: { type: 'boolean', default: false },
lastShownDonateDialog: { type: 'number', default: 0 },
Expand Down
8 changes: 7 additions & 1 deletion app/main/components/Cerebro/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from 'main/constants/ui'
import * as searchActions from 'main/actions/search'

import config from 'lib/config'
import ResultsList from '../ResultsList'
import StatusBar from '../StatusBar'
import styles from './styles.module.css'
Expand Down Expand Up @@ -123,7 +124,12 @@ function Cerebro({
const [mainInputFocused, setMainInputFocused] = useState(false)
const [prevResultsLenght, setPrevResultsLenght] = useState(() => results.length)

const focusMainInput = () => mainInput.current.focus()
const focusMainInput = () => {
mainInput.current.focus()
if (config.get('selectOnShow')) {
mainInput.current.select()
}
}

// suscribe to events
useEffect(() => {
Expand Down
8 changes: 6 additions & 2 deletions app/plugins/core/settings/Settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function Settings({ get, set }) {
proxy: get('proxy'),
developerMode: get('developerMode'),
cleanOnHide: get('cleanOnHide'),
selectOnShow: get('selectOnShow'),
pluginsSettings: get('plugins'),
crashreportingEnabled: get('crashreportingEnabled'),
openAtLogin: get('openAtLogin')
Expand All @@ -30,8 +31,6 @@ function Settings({ get, set }) {
setState((prevState) => ({ ...prevState, [key]: value }))
}

console.log(state.country)

return (
<div className={styles.settings}>
<Wrapper label="Hotkey" description="Type your global shortcut for Cerebro in this input">
Expand Down Expand Up @@ -79,6 +78,11 @@ function Settings({ get, set }) {
value={state.cleanOnHide}
onChange={(value) => changeConfig('cleanOnHide', value)}
/>
<Checkbox
label="Select input on show"
value={state.selectOnShow}
onChange={(value) => changeConfig('selectOnShow', value)}
/>
<Checkbox
label="Send automatic crash reports (requires restart)"
value={state.crashreportingEnabled}
Expand Down