[Django] #35943: Remove deprecated 'unload' event listener

15 views
Skip to first unread message

Django

unread,
Nov 26, 2024, 11:51:31 AM11/26/24
to django-...@googlegroups.com
#35943: Remove deprecated 'unload' event listener
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Type:
| Cleanup/optimization
Status: new | Component:
| contrib.admin
Version: dev | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
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 [https://github.com/fergald/docs/blob/master/explainers/permissions-
policy-deprecate-unload.md linked proposal] points to
[`pagehide`](https://developer.mozilla.org/en-
US/docs/Web/API/Window/pagehide_event) as a more reliable alternative,
which seems like it would be compatible with the goal of closing child
popups.
--
Ticket URL: <https://code.djangoproject.com/ticket/35943>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 26, 2024, 2:47:55 PM11/26/24
to django-...@googlegroups.com
#35943: Remove deprecated 'unload' event listener
--------------------------------------+------------------------------------
Reporter: Adam Johnson | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Natalia Bidart):

* stage: Unreviewed => Accepted


Old description:

> 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 [https://github.com/fergald/docs/blob/master/explainers/permissions-
> policy-deprecate-unload.md linked proposal] points to
> [`pagehide`](https://developer.mozilla.org/en-
> US/docs/Web/API/Window/pagehide_event) as a more reliable alternative,
> which seems like it would be compatible with the goal of closing child
> popups.

New description:

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 [https://github.com/fergald/docs/blob/master/explainers/permissions-
policy-deprecate-unload.md linked proposal] points to
[https://developer.mozilla.org/en-US/docs/Web/API/Window/pagehide_event
pagehide] as a more reliable alternative, which seems like it would be
compatible with the goal of closing child popups.

--
Comment:

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
[https://developer.chrome.com/docs/web-platform/deprecating-unload these
Chrome docs] we may need to evaluate `visbilitychange` as well.
--
Ticket URL: <https://code.djangoproject.com/ticket/35943#comment:1>

Django

unread,
Nov 28, 2024, 5:16:04 AM11/28/24
to django-...@googlegroups.com
#35943: Remove deprecated 'unload' event listener
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Tanish
Type: | Yelgoe
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tanish Yelgoe):

* owner: (none) => Tanish Yelgoe
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35943#comment:2>

Django

unread,
Nov 28, 2024, 7:15:22 AM11/28/24
to django-...@googlegroups.com
#35943: Remove deprecated 'unload' event listener
--------------------------------------+------------------------------------
Reporter: Adam Johnson | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tanish Yelgoe):

* owner: Tanish Yelgoe => (none)
* status: assigned => new

--
Ticket URL: <https://code.djangoproject.com/ticket/35943#comment:3>

Django

unread,
Dec 26, 2024, 1:49:36 PM12/26/24
to django-...@googlegroups.com
#35943: Remove deprecated 'unload' event listener
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner:
Type: | PoojaVishwakarma0402
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by PoojaVishwakarma0402):

* owner: (none) => PoojaVishwakarma0402
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35943#comment:2>

Django

unread,
Jan 1, 2025, 12:26:49 PMJan 1
to django-...@googlegroups.com
#35943: Remove deprecated 'unload' event listener
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Pooja
Type: | Vishwakarma
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Pooja Vishwakarma):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35943#comment:3>

Django

unread,
Jan 2, 2025, 3:25:24 AMJan 2
to django-...@googlegroups.com
#35943: Remove deprecated 'unload' event listener
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Pooja
Type: | Vishwakarma
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Pooja Vishwakarma):

PR link:
[https://github.com/django/django/pull/18977]
--
Ticket URL: <https://code.djangoproject.com/ticket/35943#comment:4>

Django

unread,
Jan 7, 2025, 6:43:09 AMJan 7
to django-...@googlegroups.com
#35943: Remove deprecated 'unload' event listener
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Pooja
Type: | Vishwakarma
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35943#comment:5>
Reply all
Reply to author
Forward
0 new messages