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

fix: allow input field to have zero value #1647

Closed
wants to merge 3 commits into from
Closed
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
Original file line number Diff line number Diff line change
@@ -24,4 +24,12 @@ describe('<Input>', () => {

expect(onKeyDown).toHaveBeenCalledTimes(1)
})

it('should render a field with value zero', () => {
const screen = render(
<InputField label="label" name="foo" type="number" value={0} />
)

expect(screen.getByLabelText('label')).toHaveValue(0)
})
})
2 changes: 1 addition & 1 deletion components/input/src/input-field/input-field.js
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ class InputField extends React.Component {
onChange={onChange}
name={name}
type={type}
value={value || ''}
value={value ?? ''}
placeholder={placeholder}
disabled={disabled}
max={max}

Unchanged files with check annotations Beta

}
return clearAllTimeouts
}, [hidden])

Check warning on line 101 in components/alert/src/alert-bar/alert-bar.js

GitHub Actions / lint

React Hook useEffect has missing dependencies: 'inDOM', 'runHideAnimation', and 'runShowAnimation'. Either include them or remove the dependency array
return !inDOM ? null : (
<div
if (initialFocus && ref.current) {
ref.current.focus()
}
}, [initialFocus, ref.current])

Check warning on line 38 in components/button/src/button/button.js

GitHub Actions / lint

React Hook useEffect has an unnecessary dependency: 'ref.current'. Either exclude it or remove the dependency array. Mutable values like 'ref.current' aren't valid dependencies because mutating them doesn't re-render the component
const { 'aria-label': ariaLabel, title } = otherProps
// the disconnect function for better readability.
return () => intersectionObserver.disconnect()
}
}, [rootRef.current, intersectionRef.current])

Check warning on line 62 in components/intersection-detector/src/intersection-detector.js

GitHub Actions / lint

React Hook useEffect has missing dependencies: 'onChange', 'rootRef', and 'threshold'. Either include them or remove the dependency array. Mutable values like 'rootRef.current' aren't valid dependencies because mutating them doesn't re-render the component
return (
<div ref={intersectionRef} className={className} data-test={dataTest}>
onExpand({ path })
setOpenedOnce(true)
}
}, [autoExpand, openedOnceDueToError])

Check warning on line 29 in components/organisation-unit-tree/src/organisation-unit-node/use-open-state.js

GitHub Actions / lint

React Hook useEffect has missing dependencies: 'onExpand' and 'path'. Either include them or remove the dependency array. If 'onExpand' changes too often, find the parent component that defines it and wrap that definition in useCallback
const open =
(autoExpand && !openedOnceDueToError) || !!expanded.includes(path)
return suppressAlphabeticalSorting
? orgUnit.children
: sortNodeChildrenAlphabetically(orgUnit.children)
}, [data, suppressAlphabeticalSorting])

Check warning on line 47 in components/organisation-unit-tree/src/organisation-unit-node/use-org-children.js

GitHub Actions / lint

React Hook useMemo has a missing dependency: 'node.children'. Either include it or remove the dependency array
useEffect(() => {
if (onComplete && orgChildren && !onCompleteCalledRef.current) {
onComplete({ ...node, children: orgChildren })
onCompleteCalledRef.current = true
}
}, [onComplete, orgChildren, onCompleteCalledRef])

Check warning on line 55 in components/organisation-unit-tree/src/organisation-unit-node/use-org-children.js

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'node'. Either include it or remove the dependency array
return { called, loading, error: error || null, data: orgChildren }
}
useEffect(() => {
const nextReloadId = reloadId + 1
forceReload === true && setReloadId(nextReloadId)
}, [forceReload])

Check warning on line 19 in components/organisation-unit-tree/src/organisation-unit-tree/use-force-reload.js

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'reloadId'. Either include it or remove the dependency array
return reloadId
}
* clear the selection.
*/
const debouncedRefetch = useCallback(debounce(refetch, 250), [refetch])

Check warning on line 37 in components/sharing-dialog/src/autocomplete/sharing-autocomplete.js

GitHub Actions / lint

React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead
useEffect(() => {
if (search && search === selected) {
onSelection(null)
setShowResults(false)
}
}, [search])

Check warning on line 50 in components/sharing-dialog/src/autocomplete/sharing-autocomplete.js

GitHub Actions / lint

React Hook useEffect has missing dependencies: 'debouncedRefetch', 'onSelection', and 'selected'. Either include them or remove the dependency array. If 'onSelection' changes too often, find the parent component that defines it and wrap that definition in useCallback
// Concatenate all the results
let results = []
useEffect(() => {
refetch({ type, id })
}, [type, id])

Check warning on line 134 in components/sharing-dialog/src/sharing-dialog.js

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'refetch'. Either include it or remove the dependency array
/**
* Block interaction during the initial load