From fb2d4087bf5a64770e2df33ee1245566055b907b Mon Sep 17 00:00:00 2001 From: John McLear Date: Fri, 24 Apr 2026 03:21:39 +0100 Subject: [PATCH] fix(editbar): restore caret to pad after toolbar-select change (#7589) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After picking a value from a toolbar elements + // aren't always wired through Button.bind (which requires data-key on + // the wrapping
  • ); covering them at the #editbar level means every + // toolbar dropdown restores focus consistently. setTimeout(0) defers + // the focus call until plugin change handlers (bound on the same + // event) have finished, so their ace.callWithAce work is done before + // we return focus. Fixes #7589. + $('#editbar').on('change', 'select', () => { + setTimeout(() => { + if (padeditor.ace) padeditor.ace.focus(); + }, 0); + }); + $('.show-more-icon-btn').on('click', () => { $('.toolbar').toggleClass('full-icons'); }); diff --git a/src/tests/frontend-new/specs/select_focus_restore.spec.ts b/src/tests/frontend-new/specs/select_focus_restore.spec.ts new file mode 100644 index 00000000000..80a36526c54 --- /dev/null +++ b/src/tests/frontend-new/specs/select_focus_restore.spec.ts @@ -0,0 +1,39 @@ +import {expect, test} from '@playwright/test'; +import {getPadBody, goToNewPad} from '../helper/padHelper'; + +test.beforeEach(async ({page}) => { + await goToNewPad(page); +}); + +test('toolbar select change returns focus to the pad editor (#7589)', async ({page}) => { + // Regression: after picking a value from a toolbar select (ep_headings + // style picker is the canonical example), the caret should return to + // the pad editor so typing continues instead of being swallowed by + // the select wrapper. + const hs = page.locator('#heading-selection'); + if ((await hs.count()) === 0) { + test.skip(true, 'ep_headings2 not enabled in this environment'); + return; + } + + const padBody = await getPadBody(page); + await padBody.click(); + await page.keyboard.type('before'); + + // Change the heading style. The native