Allow AJAX dialogs to disable refocus when content is added

Created on 4 December 2020, about 4 years ago
Updated 30 January 2023, almost 2 years ago

Problem/Motivation

When content is added to a dialog via AJAX, dialog.ajax.js sets the focus to the dialog. When trying to implement auto-saving for a form in the dialog, this results in the focus being removed from a form field after save.

Steps to reproduce

Open an AJAX form to a dialog.
Add some JS to trigger form submit on change of a form field.
The focus is removed from the form field by dialog.ajax.js.

Proposed resolution

Allow dialogs to conditionally opt-out of this behaviour. When setting the focus, we could check for a class on the dialog and skip if the dialog has that class.

        if (!$context.closest('.ui-dialog').hasClass('js-disable-refocus')) {
          $dialog.dialog('widget').trigger('focus');
        }

Remaining tasks

  1. Review.
  2. Commit.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

Feature request
Status

Needs work

Version

10.1

Component
Ajax 

Last updated about 3 hours ago

Created by

🇳🇱Netherlands seanB Netherlands

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024