URL not sumbitted (missing context in JS behavior detach

Created on 29 May 2024, about 1 year ago

Problem/Motivation

The module attaches a JS behavior to autosubmit when a URL is filled in.
once("auto-remote-url-add", "input[data-drupal-file-url-remote]", context).forEach

In some scenarios, such as on a clean core 10.3.x and file_url 2.x setup with toolbar and big_pipe modules enabled, the autosubmit doesn't work/happen.
It looks like the JS behavior is being detached, and the change event gets wrongly removed, because the context is missing as a 3rd argument:
once.remove("auto-remote-url-add", "input[data-drupal-file-url-remote]").forEach...

Steps to reproduce

- Install clean drupal core 10.3.x (standard profile with toolbar and big_pipe) + file_url 2.x
- Create a file_url field in page nodes
- Go on a page node edit/create form
- Click "Remote file URL", fill in a valid URL, and click/tab outside the input
>> Actual behavior: nothing happens
>> Expected behavior: the URL gets submitted and added as field item

Proposed resolution

Add the missing context to 3rd argument of once.remove

🐛 Bug report
Status

Active

Version

2.0

Component

User interface

Created by

🇧🇪Belgium herved

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @herved
  • 🇧🇪Belgium herved

    I created 2 branches:
    - one that simply adds the missing context in JS
    - one that replaces the URL autosubmit and JS with a "Add URL" button.

  • Merge request !10Fix #access on button controls. → (Open) created by herved
  • 🇧🇪Belgium herved

    I opened a MR for the 2nd option: replace the URL autosubmit and JS with a "Add URL" button.
    Because this is a much better approach for UX: an autosubmit on input change is very intrusive for the user and a button is a much better approach.

    I did have to refactor the #access applied on elements because having it to FALSE causes havoc.
    It seems in that case Drupal doesn't understand what button triggered the action in \Drupal\Core\Form\FormBuilder::handleInputElement and considers the first button in form_state was clicked. This causes all kinds of misbehaviors.

  • 🇧🇪Belgium herved

    This patch can be combined with 🐛 PHP warnings from FileUrlWidget Needs review which fixes another error with the widget.
    Maybe it's best to centralize both in a single issue?

  • 🇵🇱Poland alorenc Wolsztyn, 🇵🇱

    It works for me, but there is a question regarding the supported Drupal version.

  • 🇵🇱Poland alorenc Wolsztyn, 🇵🇱
Production build 0.71.5 2024