Opened 18 months ago

Closed 2 weeks ago

Last modified 13 days ago

#35943 closed Cleanup/optimization (fixed)

Remove deprecated 'unload' event listener

Reported by: Adam Johnson Owned by: Amar
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: 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 (last modified by Natalia Bidart)

Loading any ModelAdmin page in Chrome 117+ triggers this warning:

  Unload event listeners are deprecated and will be removed.
  1 source
  RelatedObjectLookups.js:203
  https://chromestatus.com/feature/5579556305502208

That’s here: https://github.com/django/django/blob/857b1048d53ebf5fc5581c110e85c212b81ca83a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js#L213-L215

The linked proposal points to pagehide as a more reliable alternative, which seems like it would be compatible with the goal of closing child popups.

Change History (15)

comment:1 by Natalia Bidart, 18 months ago

Description: modified (diff)
Triage Stage: UnreviewedAccepted

Thank you Adam for taking the time to create this ticket, and for linking adequate resources to do proper triage.

I'm accepting on the basis that this makes sense but I would like to see more research being done regarding what to use to replace unload. The linked MDN docs say:

The pagehide event is sent to a Window when the browser hides the current page in the process of presenting a different page from the session's history.
For example, when the user clicks the browser's Back button, the current page receives a pagehide event before the previous page is shown.

Is not immediately clear to me that this is a good replacement. From these Chrome docs we may need to evaluate visbilitychange as well.

comment:2 by Pooja Vishwakarma, 17 months ago

Owner: set to Pooja Vishwakarma
Status: newassigned

comment:3 by Pooja Vishwakarma, 16 months ago

Has patch: set

comment:5 by Jacob Walls, 16 months ago

Patch needs improvement: set

comment:6 by Peter van der Does, 3 months ago

Owner: changed from Pooja Vishwakarma to Peter van der Does

comment:8 by Jacob Walls, 3 months ago

Needs tests: set

comment:9 by Amar, 2 months ago

Owner: changed from Peter van der Does to Amar

comment:10 by Amar, 2 months ago

Needs tests: unset
Patch needs improvement: unset

comment:11 by Jacob Walls, 2 months ago

Needs tests: set
Owner: changed from Amar to Peter van der Does

comment:12 by Amar, 5 weeks ago

Owner: changed from Peter van der Does to Amar

comment:13 by Jacob Walls, 2 weeks ago

Needs tests: unset
Triage Stage: AcceptedReady for checkin

comment:14 by Jacob Walls <jacobtylerwalls@…>, 2 weeks ago

Resolution: fixed
Status: assignedclosed

In e1bdebc:

Fixed #35943 -- Replaced unload event listener with pagehide.

Co-authored-by: Peter van der Does <peter@…>
Co-authored-by: Jacob Walls <jacobtylerwalls@…>

comment:15 by GitHub <noreply@…>, 13 days ago

In 183e650:

Refs #35943 -- Fixed admin_views.test_related_object_lookups crash when selenium is not installed.

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