Click JavaScript to close details causes modals to scroll unnecessarily

Created on 7 January 2025, 14 days ago

Problem/Motivation

When adding a new block via the block layout page, it opens the block form in a modal. We have a field element that uses Ajax to add new fields but the scroll always takes us to the block class details. After some investigation, it seems this is because the JavaScript in block class actually "clicks" on the details pane to close causing that element to be focused and causing the modal to scroll to focus.

Steps to reproduce

Place a new block by going to /admin/structure/block and click "Place block" next to the block you wish to place that has block class enabled on it.

Notice that without doing anything, the "Attribute" details or "ID" details is focused. Then, if an Ajax request causes the modal to refresh, it will refresh to the focused element.

Proposed resolution

Replace $('.replaced-id-details').find('summary').trigger( "click" ); with $('.replaced-id-details').removeAttr("open"); for both the "Attribute" and "ID" detail pages. Looks like this same change will apply to version 4 as well. Forthcoming MR.

Remaining tasks

Create the MR.

User interface changes

None.

API changes

None

Data model changes

None

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States codechefmarc

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024