From ded9de23dbe89cf80532c2bba122457ea2be2eb4 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Thu, 6 Aug 2026 17:38:58 +0200 Subject: [PATCH] Move the form_post auto-submit script to a frontend entrypoint --- frontend/src/entrypoints/form-post.ts | 10 ++++++++++ templates/form_post.html | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 frontend/src/entrypoints/form-post.ts diff --git a/frontend/src/entrypoints/form-post.ts b/frontend/src/entrypoints/form-post.ts new file mode 100644 index 000000000..fe52c04cb --- /dev/null +++ b/frontend/src/entrypoints/form-post.ts @@ -0,0 +1,10 @@ +// Copyright 2026 Element Creations Ltd. +// +// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial +// Please see LICENSE files in the repository root for full details. + +// Submit the form on the next tick, so the browser can paint the +// placeholder before navigating away. +setTimeout(() => { + document.forms[0].submit(); +}, 0); diff --git a/templates/form_post.html b/templates/form_post.html index 71882c8ab..253c152d4 100644 --- a/templates/form_post.html +++ b/templates/form_post.html @@ -1,4 +1,5 @@ {# +Copyright 2025, 2026 Element Creations Ltd. Copyright 2024, 2025 New Vector Ltd. Copyright 2021-2024 The Matrix.org Foundation C.I.C. @@ -28,5 +29,5 @@ Please see LICENSE files in the repository root for full details. {# Submit the form in JavaScript on the next tick, so that if the browser wants to display the placeholder instead of a blank page, it can #} - + {{ include_asset('src/entrypoints/form-post.ts') | indent(2) | safe }} {% endblock %}