Opened 9 hours ago

Last modified 6 hours ago

#35943 new Cleanup/optimization

Remove deprecated 'unload' event listener — at Version 1

Reported by: Adam Johnson Owned by:
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no 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 (1)

comment:1 by Natalia Bidart, 6 hours 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.

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