Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

DatePickerInput: fixed clearing logic #2464

Merged
merged 6 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@

### Dependency updates

## [17.1.1] - 2022-11-23

### Fixed

- `DatePickerInput`: clearing logic ([@qubis741](https://github.com/qubis741)) in ([#2464](https://github.com/teamleadercrm/ui/pull/2464))

## [17.1.0] - 2022-11-22

### Changed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@teamleader/ui",
"description": "Teamleader UI library",
"version": "17.1.0",
"version": "17.1.1",
"author": "Teamleader <development@teamleader.eu>",
"bugs": {
"url": "https://github.com/teamleadercrm/ui/issues"
Expand Down
5 changes: 3 additions & 2 deletions src/components/datepicker/DatePickerInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function DatePickerInput<IsTypeable extends boolean = true>({
}
// Blurred from input, not focused on datepicker
if (value === false) {
if (typeable && !customFormatDate && inputValue) {
if (typeable && !customFormatDate) {
const date = parseMultiFormatsDate(inputValue, ALLOWED_DATE_FORMATS, locale);
if (date && isAllowedDate(date, dayPickerProps?.disabledDays)) {
onChange && onChange(date);
Expand Down Expand Up @@ -228,10 +228,11 @@ function DatePickerInput<IsTypeable extends boolean = true>({
event.preventDefault();
closePopover(undefined);
handleInputValueChange('');
setSelectedDate(undefined);
};

const renderClearIcon = () => {
return clearable && selectedDate ? (
return clearable && inputValue.length > 0 ? (
<Icon
color={inverse ? 'teal' : 'neutral'}
tint={inverse ? 'light' : 'darkest'}
Expand Down