Maintain form focus after selecting a media item

Created on 26 February 2025, about 1 month ago

Problem/Motivation

We are using this module to enable the Media Library form API element within a custom block within Layout Builder.
In trying to track down why, I've come across this issue:
https://www.drupal.org/project/drupal/issues/3089745 β†’

Which, in turn, led me to this committed fix going back to Drupal 9.1:
https://git.drupalcode.org/project/drupal/-/commit/fb46d2747fa64a6f0cfc0...

Steps to reproduce

  • Create a custom block
  • Add a "media_library" form API element into the block configuration
  • Add the block to a Layout Builder page
  • In the block configuration form, use the Media library form API element/widget to choose a media item
  • After selecting the media item, notice the focus jumps to the top of the page
  • Expectation is that focus is maintained at the same place the media item was selected, so the user can move onto th e next step with less scrolling

Proposed resolution

I think possibly we need to implement the same sort of focus fix that was made to the Media Library field widget to the Media Library Form Element.

User interface changes

The focus will be improved, leading to an improved user experience.

Forgive me if this is already addressed in 2.1.x, as I have not been able to test that since we are not yet on Drupal 10.3 and it seems that 2.1.x is making 10.3 a requirement.

πŸ“Œ Task
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States joshua.boltz

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

Comments & Activities

Production build 0.71.5 2024