-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 edit cookie shows expires as an Invalid Date #4897
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Before - date would show up as invalid, and upon closing cookie modal would dissappear:
Now - it at least doesn't show up as invalid, and isn't deleted:
It doesn't solve all our problems with cookies, but at least gets rid of the invalid date/disappear behaviour, so from my side I think we can merge. Thank you @tangweikun for contributing this 👍
What are the other related issues about cookies? You can show me the issues, I can take a deeper look another day. @filfreire |
@tangweikun if you wish to have a look, these are some that are open: |
const isInValidExpires = (val: Cookie['expires']) => val === null || val === '' || new Date(Number(val)).toString() === 'Invalid Date'; | ||
if (isInValidExpires(cookie.expires)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its better to use positive naming here isValidDate
also consider using date-fns for validation as we have it installed https://date-fns.org/v2.28.0/docs/isValid
@@ -227,7 +227,7 @@ export class UnconnectedCookieModifyModal extends PureComponent<Props, State> { | |||
</div> | |||
{this._renderInputField( | |||
'expires', | |||
isNaN(new Date(cookie.expires || 0).getTime()) ? 'Invalid Date' : null, | |||
cookie.expires !== null && new Date(Number(cookie.expires)).toString() === 'Invalid Date' ? 'Invalid Date' : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this isn't react i'd consider moving it into a condition inside of _renderInputField
if(type==='expires'){
}
After testing this PR. It is an improvement on the original but could afford to be more clear about what values are acceptable inputs to the expires field. I'm considering if we should either add support for typing in a GMT/UTCString eg. Thu, 21 Oct 2021 07:28:00 GMT
For now I think we can ignore the |
LGTM! |
@tangweikun I agree, but I don't think we have a half width convention anywhere else yet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
- Pressing the
Clear
button doesn't visible delete the date from the input field (though in the background it does seem to delete it. PressingClear
button a second time seems clear up the date.
a1b5127
to
e200f16
Compare
#4195 Fix Edit Cookie shows Expires as an Invalid Date
Suggestion:Maybe can use DatePicker instead of Input in Expires field
changelog(Fixes): Fixed an issue where editing a cookie wrongfully displayed expiry dates as invalid