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

DataTable error while using stateStorage with date filter #1020

Closed
ahmedkandel opened this issue Feb 24, 2021 · 2 comments
Closed

DataTable error while using stateStorage with date filter #1020

ahmedkandel opened this issue Feb 24, 2021 · 2 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@ahmedkandel
Copy link
Contributor

First, thank you for the great library.

I have a DataTable column with dataType="date" and using default date filter modes. When enabling stateStorage on the DataTable I got the following error:

Uncaught (in promise) TypeError: filter.getTime is not a function

After some digging, I have found that in "src > components > DataTable.vue" the saveState() is using JSON.stringify(state) which will convert date objects to ISO8601 string, Then the restoreState() is using JSON.parse(stateString) which will keep the date as string and causes error when calling date methods e.g. getTime() on it to filter.

I made a PR to fix this and will submit it soon.

ahmedkandel added a commit to ahmedkandel/primevue that referenced this issue Feb 24, 2021
@cagataycivici cagataycivici self-assigned this Feb 26, 2021
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Feb 26, 2021
@cagataycivici cagataycivici added this to the 3.3.1 milestone Feb 26, 2021
@cagataycivici
Copy link
Member

Fixed with an alternate regex, thanks.

@ahmedkandel
Copy link
Contributor Author

ahmedkandel commented Feb 26, 2021

@cagataycivici I think the alternate regex is not accurate for two cases:

  1. It will pass values like '9999-99-99T99:99:99.999Z' but when converting it to date will give an error. As the regex doesn't check correct days, months, ...
  2. It doesn't support AD/BC years which is a part of ISO 8601 e.g. ancient date “before Christ” or far future dates.

So i think mine was better. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants