Work around 8-year-old Firefox bug

If the max comments setting was changed using only the spinner, it
wasn't saved. See https://bugzilla.mozilla.org/show_bug.cgi?id=1012818
This commit is contained in:
Christopher Gurnee 2022-01-29 10:01:10 -05:00
parent fe21a0760f
commit 2f4c8e0c62

View file

@ -3,6 +3,7 @@ import {connect, sort, filter, maxCommentsLimit} from '../../state'
const sortBy = props => {
const [reloadVisible, setReloadVisible] = useState(false)
const isFirefox = typeof InstallTrigger !== 'undefined'
let usedMouse;
return (
@ -37,7 +38,11 @@ const sortBy = props => {
setReloadVisible(parseInt(e.target.value) > props.global.state.maxComments && props.global.state.maxComments < maxCommentsLimit)
}} onBlur={e => {
e.target.value = props.global.saveMaxComments(e.target.value)
}} defaultValue={props.global.state.maxComments} type='number' maxLength='5' required min='100' max={maxCommentsLimit} step='100' />
}} {
...(isFirefox ? {onClick: e => {
e.target.focus()
}} : {})
} defaultValue={props.global.state.maxComments} type='number' maxLength='5' required min='100' max={maxCommentsLimit} step='100' />
{reloadVisible && <>
<span className='space' />
<input onClick={() => {props.global.loadMaxComments(); setReloadVisible(false)}} type='button' value='Reload' />