-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Fixed #36460 -- Improve accessibility and add new feature to column sorting in admin ChangeList. #19564
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?
Conversation
d1d302d
to
9995f30
Compare
Also when testing with a screen reader, the column header is not announced with the buttons We also have no test coverage for generating screenshots with the change list which might be nice to add |
Thank you, sarahboyce. Even though I already referred to the article you provided and worked on it, reading it again made me realize that my work was lacking in many ways. I will do my best to review it carefully and redo the work. |
e5422bb
to
9eb02d4
Compare
@sarahboyce I might be misunderstanding something, but I have a question... When applying the approach where the column header is announced together with the button, it seems necessary to have only a single sort button inside each column (like in the W3C sortable table example). If we adopt this method, the sort order would cycle like this: none → ascending → descending → none Do you think the benefit of having just a single sort button per column outweighs that trade-off? |
9eb02d4
to
4a3a0de
Compare
I don't know if the @django/accessibility team has examples of accessible tables with multiple sort buttons. Currently in this PR:
|
I agree. It is common to have only one sort button. I tried to preserve the existing structure as much as possible. 😅
Yes, When the button is focused, information such as the item, sort direction, and priority should be announced.
I believe it’s best if the visual cues can be understood through color changes alone. If possible, I feel it would be better to remove the animations (I also find the current animations to be quite cluttered).
As far as I know, the |
06d96e2
to
7fd300d
Compare
45b28fa
to
712cda0
Compare
712cda0
to
e071317
Compare
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.
Thank you for the updates @Antoliny0919 ⭐
This looks promising to me
The "no sort" icon appears to be bigger or misaligned to the sorted ascending/descending icons. I also think I prefer them to be right aligned to the column as this design pattern seems to be the most common
I will let the accessibility team give feedback on the approach 👍
e071317
to
9769408
Compare
Sort priority and sort button were originally positioned on the right side of the column, and I’ve adjusted them to remain in the same position. |
Testing with Firefox 140.0.4 on Ubuntu |
0af8137
to
1471861
Compare
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.
Thank you for the updates!
table thead th.sortable:not([aria-sort]) div span:nth-last-child(2):after, | ||
table thead th.sortable[aria-sort="ascending"] div span:nth-last-child(2):after { | ||
content: "▲"; | ||
} |
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.
table thead th.sortable:not([aria-sort]) div span:nth-last-child(2):after, | |
table thead th.sortable[aria-sort="ascending"] div span:nth-last-child(2):after { | |
content: "▲"; | |
} | |
table thead th.sortable:not([aria-sort]) div span:nth-last-child(2):after { | |
content: "⇅"; | |
} | |
table thead th.sortable[aria-sort="ascending"] div span:nth-last-child(2):after { | |
content: "▲"; | |
} |
I think we need a different icon for the sortable column, as currently if I am hovering over the column and click through, it's hard to tell that there is 3 states
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.
I really like the Unicode symbol you suggested :0
I think it would be great for indicating that sorting is available.
Thank you !!!
thead th.sorted { | ||
background: var(--selected-bg); | ||
thead th.sorted, | ||
table thead th.sortable a:hover { |
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.
table thead th.sortable a:hover { | |
table thead th.sortable:hover { |
This issue was pre-existing but it is more pronounced when the background is blue. Currently only the inner background changes on hover (and I don't like it personally)
This suggestion doesn't quite work because when you are on the th
boarder, rather than the a
tag, the text is grey and unreadable but hopefully you understand what I mean
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.
You mean that in light mode, when you hover the pointer over the edge of a th
, the background color of the th
changes but the text color does not, making it hard to distinguish, right?
I think it should be fine to revert the background color back to the original 😁
(foreground color will be fixed to a single color.)

--table-sorted-bg: #447996; | ||
--table-sorted-fg: #fff; |
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.
I personally preferred using shades of grey for the sorted columns but that is just personal preference (not sure if we have any design spec around colors)
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.
I agree.
In fact, the main reason I changed the background color was because I was trying to indicate sorting using only two characters("▲", "▼")
model_admin=cl.model_admin, | ||
return_attr=True, | ||
) | ||
priority_description += "%s priority %d, " % (text, index + 1) |
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.
We should probably make all descriptions translatable and you might want to think how best to make this clear for translators
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.
I've been thinking about this, and how about making it like this?
_("Next sort direction, %(direction)s, Sort priority, %(priority)s")
The sentence will probably be something like the following...
"Next sort direction, ascending, Sort priority, col_xx, col_yy, col_zz"
Could I get some advice on this part? 🥲
…umn sorting in admin ChangeList.
1471861
to
f2a4638
Compare
Trac ticket number
ticket-36460
Branch description
I updated the design of the
ChangeList
column sorting to improve accessibility.Checklist
main
branch.