TimePicker component is always valid after an input selection
Describe the issue. What is the expected and unexpected behavior?
The validationTime function passed as props doesn't work because the component is always set to valid after an input.
https://github.com/patternfly/patternfly-react/blob/34bc1ee55119b5d6396168a0824be4a2280ec2d7/packages/react-core/src/components/TimePicker/TimePicker.tsx#L297-L306
It should take into account the isValid function.
Please provide the steps to reproduce. Feel free to link CodeSandbox or another tool. The code below should render a TimePicker component that is always invalid, but it doesn't.
const [value, setValue] = useState<string>()
const validateTime = useCallback((time: string) => false, []);
return (
<TimePicker
value={value}
onChange={setValue}
validateTime={validateTime}
is24Hour
/>
Is this a bug or enhancement? If this issue is a bug, is this issue blocking you or is there a work-around? Bug
What is your product and what release version are you targeting? kiegroup/kogito-tooling: 0.10.0 aerogear/uniforms-patternfly: 4.6.1
patternfly/[email protected]
I am assuming you use some version of PF, would be worth it to insert it in the issue description. I had a similar issue a while back, https://github.com/patternfly/patternfly-react/issues/5565 but it's already fixed, first in @patternfly/[email protected]
I just tried this example in the docs and it behaves as expected:
import React from 'react';
import { TimePicker } from '@patternfly/react-core';
SimpleTimePicker = () => {
const onChange = (time) => {
console.log(time);
};
return <TimePicker validateTime={() => false} time="3:35 AM" onChange={onChange}/>;
}
@KKoukiou Hi! I'm sorry. I didn't put the version on the description as the bug is on the main branch as I've shown on the issue description. I've just downlaod the @4.135.0 and the bug still occours.
Here is a small video of the issue:
https://user-images.githubusercontent.com/24302289/124961291-a6000c00-dff3-11eb-9b0c-2df06415f05d.mp4
When you select a new input (use the onInputChange) the isInvalid is set to false. If you click on any other place, without selecting a new input, then it will maintain the invalid state.