Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#33491 closed Cleanup/optimization (fixed)

Rows are selected only on Chrome when going back from the confirmation page.

Reported by: Akihito Yokose Owned by: Marcelo Galigniana
Component: contrib.admin Version: 3.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: no

Description

On the admin site, I've found a feature that existed in Django 2.2 but was lost with the update to Django 3.2.

In Django 2.2, if you clicked the "No, take me back" button on the delete confirmation page, the background color of the checked rows would remain highlighted and the action-counter display would remain counted up on the change list page. However, in Django 3.2, the background color of the selected row is not highlighted and the action-counter display is "0 of X selected" (see attached images).

The reason for this is probably that the following process in django/contrib/admin/static/admin/js/actions.js was removed during the update to Django 3.2.

// Show counter by default
$(options.counterContainer).show();
// Check state of checkboxes and reinit state if needed
$(this).filter(":checked").each(function(i) {
    $(this).parent().parent().toggleClass(options.selectedClass);
    updateCounter();
    if ($(options.acrossInput).val() === 1) {
        showClear();
    }
});

A related Issue is https://github.com/django/django/pull/12820.

Attachments (4)

image_01.png (55.3 KB ) - added by Akihito Yokose 3 years ago.
image_02.png (48.9 KB ) - added by Akihito Yokose 3 years ago.
django_2_2.mp4 (144.4 KB ) - added by Mariusz Felisiak 3 years ago.
django_3_2.mp4 (157.2 KB ) - added by Mariusz Felisiak 3 years ago.

Download all attachments as: .zip

Change History (16)

by Akihito Yokose, 3 years ago

Attachment: image_01.png added

by Akihito Yokose, 3 years ago

Attachment: image_02.png added

by Mariusz Felisiak, 3 years ago

Attachment: django_2_2.mp4 added

by Mariusz Felisiak, 3 years ago

Attachment: django_3_2.mp4 added

comment:1 by Mariusz Felisiak, 3 years ago

Resolution: needsinfo
Status: newclosed
Summary: Missing feature in actions.js (Django 3.2 and later)Selected rows are not highlighted when going back from the confirmation page.

For me, it works exactly the same in Django 2.2 and 3.2, in both cases rows are not highlighted or selected. Can you provide a sample project that reproduces this issue?

comment:2 by Akihito Yokose, 3 years ago

Mariusz, thanks for the info.

It may depend on your browser.
The results I checked on my Windows PC are as follows.

Chrome 98 and Edge 98:

  • Django 2.2: OK
  • Django 3.2: NG

However, the situation was different with Firefox.

Firefox 96:

  • Django 2.2: NG
  • Django 3.2: NG

comment:3 by Mariusz Felisiak, 3 years ago

Has patch: set
Needs tests: set
Patch needs improvement: set
Resolution: needsinfo
Status: closednew
Summary: Selected rows are not highlighted when going back from the confirmation page.Rows are selected only on Chrome when going back from the confirmation page.
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

Thanks for details. I'd say it was an intended feature, since it's browser specific. IMO, we should enforce clearing checkboxes, instead of highlighting rows on Chrome. This would make this behavior browser-agnostic

Version 0, edited 3 years ago by Mariusz Felisiak (next)

comment:4 by Mariusz Felisiak, 3 years ago

Has patch: unset
Needs tests: unset
Patch needs improvement: unset

comment:5 by Mariusz Felisiak, 2 years ago

Cc: Marcelo Galigniana added

comment:6 by Marcelo Galigniana, 2 years ago

Owner: changed from nobody to Marcelo Galigniana
Status: newassigned

comment:7 by Marcelo Galigniana, 2 years ago

Has patch: set

comment:8 by Carlton Gibson, 2 years ago

Patch needs improvement: set

comment:9 by Marcelo Galigniana, 2 years ago

Patch needs improvement: unset

comment:10 by Carlton Gibson, 2 years ago

Triage Stage: AcceptedReady for checkin

comment:11 by Carlton Gibson <carlton@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In 0aa2f16e:

Fixed #33491 -- Fixed change-list selected row-highlight on cancelled delete.

Selected rows where not highlighted when returning to the change-list
after clicking "No, take me back" on the deletion confirmation page.

This commit uses the CSS :has() pseudo-class to apply the highlight
without requiring the .selected class, which is added by JavaScript
on the click event.

Once all supported browsers have :has() available, the .selected
selector and the JavaScript to add the class can be removed.

Co-authored-by: Carlton Gibson <carlton.gibson@…>

comment:12 by Carlton Gibson <carlton@…>, 2 years ago

In e1056ed5:

Refs #33491 -- Split CSS selected-row highlight selectors.

Combined selectors break the whole rule where :has() is not supported,
for example on Firefox.

Thanks to Marcelo Galigniana for the report.

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