The current text_with_summary widget adds the “Edit summary” button with JavaScript and appends it inside the Body label. Activating it moves the control and replaces it.
This example deliberately loses focus
The Before behaviour is the defect: after you activate the toggle, focus falls to the page body and the button is a different element. Use reset (reload) to start again. The rest of the page does not move.
What to check
- Tab to the “Edit summary” link. It is a
buttoninside the Bodylabel. - In the browser accessibility inspector, the Body textarea is named “Body (Edit summary)”. The control’s text is part of the field’s name.
- Press Enter or Space. The summary appears, focus leaves the control, and a new “Hide summary” control exists inside the Summary label.
- The control has no
aria-expandedand noaria-controls. Its position changes, and the Summary textarea is only named “Summary”. - This is simplified markup. It reproduces the structure, the name and the focus loss, not Drupal’s exact jQuery timing.
Next: the persistent disclosure.