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

Sort button should indicate the current sorting order (ascending or descending) #7830

Closed
2 tasks done
Geeyun-JY3 opened this issue Jul 1, 2022 · 7 comments · Fixed by #7831
Closed
2 tasks done

Sort button should indicate the current sorting order (ascending or descending) #7830

Geeyun-JY3 opened this issue Jul 1, 2022 · 7 comments · Fixed by #7831
Assignees
Labels
bug Something is broken. good first issue Opportunity for newcoming contributors.
Milestone

Comments

@Geeyun-JY3
Copy link
Collaborator

Geeyun-JY3 commented Jul 1, 2022

Describe the issue

The sort button is always the same (sort-ascending) after the page is loaded.

I already tried

  • I've read and searched the documentation.
  • I've searched for similar issues in this repository.

Steps to reproduce the behavior

  1. Go to any page with the sort button
  2. Click the sort button
  3. See that the order is changed but the sort button wouldn't change to another(sort-descending to sort-descending or verse vice) after the page is loaded

Expected behavior

The sort button should indicate the current sorting order (ascending or descending).

Screenshots

weblate sort button

Exception traceback

No response

How do you run Weblate?

weblate.org service

Weblate versions

No response

Weblate deploy checks

No response

Additional context

No response

@nijel nijel added bug Something is broken. good first issue Opportunity for newcoming contributors. labels Jul 1, 2022
@nijel nijel added this to the 4.14 milestone Jul 1, 2022
@Geeyun-JY3

This comment was marked as resolved.

@github-actions
Copy link

github-actions bot commented Jul 1, 2022

This issue seems to be a good fit for newbie contributors. You are welcome to contribute to Weblate! Don't hesitate to ask any questions you would have while implementing this.

You can learn about how to get started in our contributors documentation.

@ParthS007
Copy link
Member

ParthS007 commented Jul 1, 2022

@nijel Can you please point me to code of the desired sort button or you can also point me to instructions to find this in UI. Thanks

Edit 1: I found the button. Should we keep a tool tip for showing the current order, this is how tooltip looks like.

Screenshot 2022-07-01 at 14 46 41

@nijel
Copy link
Member

nijel commented Jul 4, 2022

I think the issue is not only about missing tooltip, but that the button looks same regardless sorting order.

@Geeyun-JY3 Geeyun-JY3 changed the title Sort button should indicate the current order (ascending or descending) Sort button should indicate the current sorting order (ascending or descending) Jul 4, 2022
@ParthS007
Copy link
Member

ParthS007 commented Jul 5, 2022

@nijel I looked into it more, the logic here seems alright. The root cause is re-render of the page on every click of change in sorting order. We receive a preset value for sort_dropdown_value and we don't persist the sort order.

What do you think of adding another param in the request for the current sort order and using that for evaluating the class(asc, desc) of toggle.

Edit 2: Specifically, I mean adding a sort_order field in UserSearchForm and SearchForm, I will update the PR with that and please let me know if you have any other suggestions.

Edit 3: After investigating a bit more, the toggle seems to happen here actually.

@nijel
Copy link
Member

nijel commented Jul 11, 2022

The order is implied in the order string - for example '-priority' and 'priority'. That is the logic implemented here:

// Show the correct toggle button
if ($(".sort-field").length) {
var sort_name = $("#query-sort-dropdown span.search-label").text();
var sort_dropdown_value = $(".sort-field li a")
.filter(function () {
return $(this).text() == sort_name;
})
.data("sort");
var sort_value = $("#id_sort_by").val();
if (sort_dropdown_value) {
if (
sort_value.replace("-", "") === sort_dropdown_value.replace("-", "") &&
sort_value !== sort_dropdown_value
) {
$("#query-sort-toggle .asc").hide();
$("#query-sort-toggle .desc").show();
} else {
$("#query-sort-toggle .desc").hide();
$("#query-sort-toggle .asc").show();
}
}
}

Maybe it's just not working properly or is not triggered, I think this used to work in the past.

@github-actions
Copy link

Thank you for your report; the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken. good first issue Opportunity for newcoming contributors.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants