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

Sorting not working on Firefox #7

Open
arobert3434 opened this issue Mar 6, 2020 · 8 comments
Open

Sorting not working on Firefox #7

arobert3434 opened this issue Mar 6, 2020 · 8 comments

Comments

@arobert3434
Copy link

arobert3434 commented Mar 6, 2020

Firefox 68.5. The tableWillUpdate() function fires, and the column arrow icon will change, but nothing else. No errors on console. Meanwhile, on Chrome, same exact HTML page sorting works fine. Update in general seems OK on Firefox, since table 'searchField' works perfectly on both.

@arobert3434
Copy link
Author

I've debugged a bit why it is failing, and in fact not really working on other browsers either. The sorting relies on a nativeCompare() function in utils.js, which tries to detect if the item is a number or a date, before treating it as a string. Unfortunately the date detection function _isDate() is not good. It tries to construct a new Date() with the string, then executes if (_isNumber(d.getTime())). However invalid dates return NaN for getTime and isNumber happily calls that a number. A minimal fix would be to not accept NaN as a number:

export const _isNumber = num => typeof num === 'number' && !isNaN(num)

I'd submit a patch but it's just a one-liner.

@gandy92
Copy link

gandy92 commented Apr 19, 2020

I have the same problem: Only one column that contains dates is sortable, all others with strings not.
I'd like to check if your solutions works with my table but i don't know how to apply the fix. Do you have a compiled fixed script I can try?

@arobert3434
Copy link
Author

Uploaded. (Change extension to .js) I'll try to submit a pull request later. Please post here if it works or not thanks.

table-sortable.txt

@gandy92
Copy link

gandy92 commented Apr 21, 2020

Works like a charm, thanks!

I may want to try a few things, may I ask you to point me in the right direction to learn how to build the project into a .js file?

@arobert3434
Copy link
Author

@gandy92 Unfortunately I haven't had time to dive in and learn this..

@gandy92
Copy link

gandy92 commented Apr 24, 2020

@arobert3434 Sorry for not being specific on my request. Obviously you know how to make the compact table-sortable.js from source. Which tools would I need to do that? If OS is relevant, I'm working with Linux.

@arobert3434
Copy link
Author

I don't. I just edited the raw minimized file. O-:

@gandy92
Copy link

gandy92 commented Apr 24, 2020

Oh. I see. 8-/ Hats off!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants