Skip to content

fix: keep the submit button from growing while the form is submitting - #2989

Open
johansolve wants to merge 1 commit into
Codeinwp:masterfrom
johansolve:fix/form-spinner-button-size
Open

fix: keep the submit button from growing while the form is submitting#2989
johansolve wants to merge 1 commit into
Codeinwp:masterfrom
johansolve:fix/form-spinner-button-size

Conversation

@johansolve

Copy link
Copy Markdown

Closes #2986.

Summary

The loading spinner is appended as a <span class="spinner"> inside the submit button, and it carried padding: 2rem. The button therefore grew — mostly in height — for as long as the submission was in flight, then shrank back. On a centered button the surrounding layout moves with it.

The ring itself is drawn by :before with position: absolute, its own width/height and negative margins for centering, so the span never needed a box of its own. It is now sized to the ring instead.

Second change on the same element: the ring's colour defaulted to white, which assumes a dark button. --submit-color is only set when the user picks a submit text colour in the block, so out of the box the spinner is white — invisible on any light or brightly coloured button. Since the span sits inside the button, currentColor inherits the button's own text colour and works on both light and dark.

Screenshots

Measured on a 46px-tall button with a lime background and dark text:

Button height, idle Button height, submitting Spinner visible
Before 46px grows no (white on lime)
After 46px 46px yes

Test instructions

  1. Add a Form block to a page and give the submit button a visible padding and a light background colour.
  2. Submit the form on the frontend and watch the button while the request is pending.
  3. Before: the button grows and the spinner cannot be seen. After: the button keeps its height and the spinner is drawn in the button's text colour.
  4. Check a dark button too, where the ring previously showed: it still does, now inheriting the text colour rather than being hard-coded white.

The change is two declarations in style.scss. I verified the compiled output and the resulting geometry in a browser against a real form, but I could not run the E2E suite locally — it needs wp-env and Docker was unavailable on this machine.

If you would rather keep white as the fallback for backwards compatibility, dropping the padding alone still fixes the reported bug — happy to trim the PR to that.

Checklist before the final review

  • Included E2E or unit tests for the changes in this PR.
  • Visual elements are not affected by independent changes.
  • It is at least compatible with the minimum WordPress version.
  • It loads additional script in frontend only if it is required.
  • Does not impact the Core Web Vitals.
  • In case of deprecation, old blocks are safely migrated.
  • It is usable in Widgets and FSE.
  • Copy/Paste is working if the attributes are modified.

This is a visual change by definition — the spinner is the visual element in question, and the button around it stops moving. No tests included: asserting "the button does not change height mid-request" needs an intercepted, held-open submission in E2E. I can write that if you want it.


Created with help of Claude Code.

The spinner is appended inside the submit button and carried 2rem of
padding, so the button grew while the request was pending and shrank back
afterwards. The ring is drawn absolutely positioned by :before with its own
dimensions, so the span only needs to be the size of the ring.

The ring also defaulted to white, which is invisible on a light button.
Since the span sits inside the button, currentColor picks up the button's
own text colour instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Submit button grows while submitting: the spinner carries 2rem of padding inside the button

1 participant