Opened 16 months ago
Closed 16 months ago
#34696 closed Cleanup/optimization (fixed)
Actions selection counter gets cleared when using Chrome's back button
Reported by: | Cauê Thenório | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 4.2 |
Severity: | Normal | Keywords: | |
Cc: | Marcelo Galigniana | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | yes |
Description (last modified by )
When using Chrome, in Admin's change list page, the actions selection counter (e.g. "99 of 100 selected") will be reset/get out of sync if the user leaves the page and then returns via the browser's back button but the rows will continue selected.
Steps to reproduce:
- Open the admin's change list page
- Select some rows, e.g. 10 rows
- The selection counter text will display "99 of X selected"
- Click on any link to navigate to another page
- Click the browser's back button
- The 10 rows will continue selected
What happens:
- The selection counter text will wrongly display "0 of X selected"
What should happen:
- The selection counter text should display "10 of X selected"
Tested on MacOS Google Chrome Version 113.0.5672.12
Change History (8)
comment:1 by , 16 months ago
Description: | modified (diff) |
---|---|
Summary: | Actions selection counter gets cleared when using back button → Actions selection counter gets cleared when using Chrome's back button |
comment:2 by , 16 months ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → Cleanup/optimization |
comment:3 by , 16 months ago
Row selections are preserved when using browser's "Back" in Chrome only. As far as I'm aware, this is not an intended feature
Correct! I did a fix to force the uncheck: https://code.djangoproject.com/ticket/33491. Seems we have a bug + add/force the row counter reset!
Cauê Thenório, do you want to work in a patch?
comment:4 by , 16 months ago
I did a test here with different browsers on MacOS, selecting some rows, navigating away and getting back:
- Chrome 113 keeps rows selected and the counter is reset ❌
- Safari 16.5 keeps rows selected and the counter is updated ✅
- Firefox 115 clear selection and the counter is updated ✅
Each browser has a different behavior but only Chrome gets the counter out of sync.
Yes Marcelo Galigniana, I would like to work on a patch. I believe it will be a couple of the lines, to call the updateCounter
function when the page loads.
comment:5 by , 16 months ago
After some tests, I found out that Chrome restores the selection after Actions(actionsEls)
is executed, therefore calling updateCounter
in the body of Actions
function won't work as Chrome didn't restore the selection at that point.
In this comment: https://bugs.chromium.org/p/chromium/issues/detail?id=1057463#c5
A Chrome developer states the values are restored before the pageshow
event: https://developer.mozilla.org/en-US/docs/Web/API/Window/pageshow_event
I'll write a patch to run updateCounter
when the pageshow
event is triggered.
comment:7 by , 16 months ago
Triage Stage: | Accepted → Ready for checkin |
---|
Thanks for the report. Row selections are preserved when using browser's "Back" in Chrome only. As far as I'm aware, this is not an intended feature, however we should keep the counter in sync or uncheck the rows.