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 #3559: Component: Calendar -> keepInvalid no longer works #3561

Merged
merged 3 commits into from
Nov 2, 2022
Merged
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const Calendar = React.memo(
}
} catch (err) {
//invalid date
const value = props.keepInvalid ? rawValue : null;
const value = props.keepInvalid ? event.value : null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think the line need to be this...

const value = props.keepInvalid ? null : rawValue;

if you try your with keepInvalid it works but if you remove keepInvalid its allowing invalid characters

Copy link
Contributor Author

@cerbugabriel cerbugabriel Nov 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference between keepInvalid true and false should only be on onBlur.
You can input invalid characters with it true and false, but, when onBlur state value remains on keepInvalid = true, and on keepInvalid = false makes the state value null. (please test the old version too (8.7.1)

I'm trying to upgrade from 6.6 and it worked as i said, now is broken.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description of keepInvalid from docs:

keepInvalid boolean false Keep invalid value when input blur.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just try your fix above with both keepInvalid={true} and keepInvalid={false} you will see your fix does NOT work. Then try mine you will see it does work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a couple of digging and found out why it didn't update. updateInputField didn't work properly.

Copy link
Contributor Author

@cerbugabriel cerbugabriel Nov 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change of:

formattedValue = isValidDate(value) ? formatDateTime(value) : '';

To

formattedValue = isValidDate(value) ? formatDateTime(value) : props.keepInvalid ? 'value' : ''

Is also a possibility


updateModel(event, value);
}
Expand Down