Opened 10 years ago
Closed 10 years ago
#30817 closed defect (bug) (fixed)
wpview: Delegate focus to opened modal on edit
Reported by: | danielbachhuber | Owned by: | |
---|---|---|---|
Milestone: | 4.2 | Priority: | normal |
Severity: | normal | Version: | 4.0 |
Component: | TinyMCE | Keywords: | needs-testing |
Focuses: | javascript | Cc: |
Description
Shortcake (Shortcode UI) uses wpviews to preview a rendered shortcode in TinyMCE. It offers a Backbone-based modal for editing shortcode attributes.
When a user clicks the wpviews edit icon though, the focus remains on the editor, instead of being delegated to the modal. The behavior was added in r29298: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js#L334
It would be nice if we could delegate focus to the modal: https://github.com/fusioneng/Shortcake/issues/66
Change History (8)
This ticket was mentioned in Slack in #core by danielbachhuber. View the logs.
10 years ago
#4
@
10 years ago
Leaving this open for further investigation/testing. It seems sometimes in Chrome the modal is not focused when used for the first time.
#6
@
10 years ago
Confirmed r30986 is a valid fix. I wasn't able to reproduce your buggy Chrome behavior, either.
The
editor.focus();
is needed for IE. All versions of IE treat non-editable elements in the editor (and even block elements with height/width set) as separate DOM fragments when selected, i.e. when the thick diagonal border with resize handles is shown.As the wpView toolbar is inside the non-editable element, the focus is transferred there on clicking a button. We hide the IE border, but the focus remains inside that DOM fragment which is outside of the editor DOM. That causes range errors when the wpView gets updated.
To fix this we can move the focus back to the editor before opening the modal, only in IE.