#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 Cauê Thenório)

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:

  1. Open the admin's change list page
  2. Select some rows, e.g. 10 rows
  3. The selection counter text will display "99 of X selected"
  4. Click on any link to navigate to another page
  5. Click the browser's back button
  6. 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 Cauê Thenório, 17 months ago

Description: modified (diff)
Summary: Actions selection counter gets cleared when using back buttonActions selection counter gets cleared when using Chrome's back button

comment:2 by Mariusz Felisiak, 17 months ago

Cc: Marcelo Galigniana added
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

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.

comment:3 by Marcelo Galigniana, 17 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

Is not intended, but that is how Chrome works and if I'm not wrong we decided no reset the checkboxes status (https://github.com/django/django/pull/15938#issuecomment-1214660476)

I remember I did a fix after go back to preserve the highlighting of the rows: https://code.djangoproject.com/ticket/33491.

We should force the counter sync.

Cauê Thenório, do you want to work in a patch?

Last edited 17 months ago by Marcelo Galigniana (previous) (diff)

comment:4 by Cauê Thenório, 17 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.

Last edited 17 months ago by Cauê Thenório (previous) (diff)

comment:5 by Cauê Thenório, 17 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.

Last edited 17 months ago by Cauê Thenório (previous) (diff)

comment:7 by Mariusz Felisiak, 16 months ago

Triage Stage: AcceptedReady for checkin

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 16 months ago

Resolution: fixed
Status: newclosed

In f7cfa482:

Fixed #34696 -- Updated selection counter in admin changelist on Chrome.

Note: See TracTickets for help on using tickets.
Back to Top