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 is different between browsers #218

Closed
Miepee opened this issue May 5, 2023 · 1 comment · Fixed by #261
Closed

Sorting is different between browsers #218

Miepee opened this issue May 5, 2023 · 1 comment · Fixed by #261
Assignees
Labels
A-room-directory Room directory landing page where you can explore the list of rooms help wanted PR's welcome to fix this issue. It probably has a potential solution documented in the issue. T-Defect Something isn't working. Bugs, crashes, or other reported issues.

Comments

@Miepee
Copy link

Miepee commented May 5, 2023

Sorting is different between browsers when viewing the room directory homepage:

Firefox 112.0.2 (unexpected weird sort ❌) Chromium 112.0.5615.165 (expected ✅)
grafik grafik

Not sure how Safari behaves.


As discussed in Matrix Public Archive room

@MadLittleMods MadLittleMods added T-Defect Something isn't working. Bugs, crashes, or other reported issues. A-room-directory Room directory landing page where you can explore the list of rooms labels May 5, 2023
@MadLittleMods
Copy link
Contributor

Reminds me of matrix-org/matrix.org#965 (another Firefox only issue with inexplicable sorting differences)

@MadLittleMods MadLittleMods added the help wanted PR's welcome to fix this issue. It probably has a potential solution documented in the issue. label May 10, 2023
@MadLittleMods MadLittleMods self-assigned this Jun 2, 2023
MadLittleMods added a commit that referenced this issue Jun 2, 2023
Fix #218

This stems from the fact that `[1, 2, 3, 4, 5].sort((a, b) => 1)` returns different results in Chrome vs Firefox (found from https://stackoverflow.com/questions/55039157/array-sort-behaves-differently-in-firefox-and-chrome-edge)

 - Chrome: `[1, 2, 3, 4, 5].sort((a, b) => 1)` -> `[1, 2, 3, 4, 5]`
 - Firefox: `[1, 2, 3, 4, 5].sort((a, b) => 1)` -> `[ 5, 4, 3, 2, 1 ]`
MadLittleMods added a commit that referenced this issue Jun 2, 2023
Room cards will now sort by room members descending (highest to lowest) as expected. 

Fix #218

The `/publicRooms` (room directory) endpoint already returns rooms in the correct order which is why we didn't care about the order before but the different `[].sort(...)` implementations in browsers necessitates we be explicit about it. Ideally, we wouldn't have to use the `ObservableMap.sortValues()` method at all but it seems like one of the only ways to get the values out. In any case, maybe it's more clear what order things are in now.

This bug stems from the fact that `[1, 2, 3, 4, 5].sort((a, b) => 1)` returns different results in Chrome vs Firefox (found from https://stackoverflow.com/questions/55039157/array-sort-behaves-differently-in-firefox-and-chrome-edge)

 - Chrome: `[1, 2, 3, 4, 5].sort((a, b) => 1)` -> `[1, 2, 3, 4, 5]` ✅ 
 - Firefox: `[1, 2, 3, 4, 5].sort((a, b) => 1)` -> `[5, 4, 3, 2, 1]` ❌
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-room-directory Room directory landing page where you can explore the list of rooms help wanted PR's welcome to fix this issue. It probably has a potential solution documented in the issue. T-Defect Something isn't working. Bugs, crashes, or other reported issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants