-
Notifications
You must be signed in to change notification settings - Fork 197
fix: treat filter datetime inputs as local; convert to UTC on apply #2571
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -57,7 +57,11 @@ | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| function addCondition() { | ||||||||||||||||||||||||
| const newTag = generateTag(selectedColumn, operatorKey, value || arrayValues); | ||||||||||||||||||||||||
| const preparedValue = | ||||||||||||||||||||||||
| column?.type === 'datetime' && typeof value === 'string' && value | ||||||||||||||||||||||||
| ? new Date(value).toISOString() | ||||||||||||||||||||||||
| : value; | ||||||||||||||||||||||||
|
Comment on lines
+60
to
+63
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for datetime conversion. This conversion logic has the same issue as in Apply this diff to add error handling: - const preparedValue =
- column?.type === 'datetime' && typeof value === 'string' && value
- ? new Date(value).toISOString()
- : value;
+ let preparedValue = value;
+ if (column?.type === 'datetime' && typeof value === 'string' && value) {
+ const date = new Date(value);
+ if (!isNaN(date.getTime())) {
+ preparedValue = date.toISOString();
+ }
+ }
const newTag = generateTag(selectedColumn, operatorKey, preparedValue || arrayValues);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| const newTag = generateTag(selectedColumn, operatorKey, preparedValue || arrayValues); | ||||||||||||||||||||||||
| if (localTags.some((t) => t.tag === newTag.tag && t.value === newTag.value)) { | ||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||
|
|
@@ -66,7 +70,7 @@ | |||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| id: selectedColumn, | ||||||||||||||||||||||||
| operator: operatorKey, | ||||||||||||||||||||||||
| value: value, | ||||||||||||||||||||||||
| value: preparedValue, | ||||||||||||||||||||||||
| arrayValues: arrayValues | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
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.
Add error handling for datetime conversion.
The conversion from datetime-local string to UTC ISO lacks error handling. If
valuecontains an invalid datetime string,new Date(value)returns an Invalid Date object, and callingtoISOString()on it will throw aTypeError, potentially crashing the filter application.Apply this diff to add error handling:
📝 Committable suggestion
🤖 Prompt for AI Agents