-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(DatePicker): error not showing on date reset by button (#9267)
* fix(DatePicker): clear error on date reset * feat(DatePicker): add clear date example to controlled DatePicker * test(DatePicker): add integration test for clear date * feat(DatePicker): update clear date logic based on #9373 * fix(DatePicker): hide error when date cleared and not required + show error when cleared and required * refactor(DatePicker) * fix(DatePicker): prop removal
- Loading branch information
1 parent
3707ffb
commit 4fccdaf
Showing
6 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/react-core/src/components/DatePicker/examples/DatePickerControlledRequired.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import { Button, DatePicker, Flex, FlexItem } from '@patternfly/react-core'; | ||
|
||
export const DatePickerControlled: React.FunctionComponent = () => { | ||
const initialValue = '2020-03-17'; | ||
const [value, setValue] = React.useState(initialValue); | ||
return ( | ||
<React.Fragment> | ||
<DatePicker | ||
requiredDateOptions={{ isRequired: true, emptyDateText: 'Date is required' }} | ||
value={value} | ||
onChange={(_event, value) => setValue(value)} | ||
/> | ||
<br /> | ||
<br /> | ||
<Flex> | ||
<FlexItem> | ||
<Button onClick={() => setValue(initialValue)}>Reset date</Button> | ||
</FlexItem> | ||
<FlexItem> | ||
<Button onClick={() => setValue('')}>Clear date</Button> | ||
</FlexItem> | ||
</Flex> | ||
</React.Fragment> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters