Settings: disable autofocus of search input

Fixes #1856.
pull/1862/head
Simon Legner 2 years ago
parent d7155c5b47
commit 7e0dacb92b

@ -12,6 +12,7 @@ class app.Settings
'layout' 'layout'
'size' 'size'
'tips' 'tips'
'noAutofocus'
'autoInstall' 'autoInstall'
'spaceScroll' 'spaceScroll'
'spaceTimeout' 'spaceTimeout'

@ -34,6 +34,9 @@ app.templates.settingsPage = (settings) -> """
<input type="checkbox" form="settings" name="layout" value="_sidebar-hidden"#{if settings['_sidebar-hidden'] then ' checked' else ''}>Automatically hide and show the sidebar <input type="checkbox" form="settings" name="layout" value="_sidebar-hidden"#{if settings['_sidebar-hidden'] then ' checked' else ''}>Automatically hide and show the sidebar
<small>Tip: drag the edge of the sidebar to resize it.</small> <small>Tip: drag the edge of the sidebar to resize it.</small>
</label> </label>
<label class="_settings-label _hide-on-mobile">
<input type="checkbox" form="settings" name="noAutofocus" value="_no-autofocus"#{if settings.noAutofocus then ' checked' else ''}>Disable autofocus of search input
</label>
<label class="_settings-label"> <label class="_settings-label">
<input type="checkbox" form="settings" name="autoInstall" value="_auto-install"#{if settings.autoInstall then ' checked' else ''}>Automatically download documentation for offline use <input type="checkbox" form="settings" name="autoInstall" value="_auto-install"#{if settings.autoInstall then ' checked' else ''}>Automatically download documentation for offline use
<small>Only enable this when bandwidth isn't a concern to you.</small> <small>Only enable this when bandwidth isn't a concern to you.</small>

@ -14,6 +14,7 @@ class app.views.SettingsPage extends app.View
settings.theme = app.settings.get('theme') settings.theme = app.settings.get('theme')
settings.smoothScroll = !app.settings.get('fastScroll') settings.smoothScroll = !app.settings.get('fastScroll')
settings.arrowScroll = app.settings.get('arrowScroll') settings.arrowScroll = app.settings.get('arrowScroll')
settings.noAutofocus = app.settings.get('noAutofocus')
settings.autoInstall = app.settings.get('autoInstall') settings.autoInstall = app.settings.get('autoInstall')
settings.analyticsConsent = app.settings.get('analyticsConsent') settings.analyticsConsent = app.settings.get('analyticsConsent')
settings.spaceScroll = app.settings.get('spaceScroll') settings.spaceScroll = app.settings.get('spaceScroll')

@ -39,12 +39,16 @@ class app.views.Search extends app.View
return return
focus: => focus: =>
@input.focus() unless document.activeElement is @input return if document.activeElement is @input
return if app.settings.get('noAutofocus')
@input.focus()
return return
autoFocus: => autoFocus: =>
unless app.isMobile() or $.isAndroid() or $.isIOS() return if app.isMobile() or $.isAndroid() or $.isIOS()
@input.focus() unless document.activeElement?.tagName is 'INPUT' return if document.activeElement?.tagName is 'INPUT'
return if app.settings.get('noAutofocus')
@input.focus()
return return
onWindowFocus: (event) => onWindowFocus: (event) =>

Loading…
Cancel
Save