Skip to content

[BootstrapAdminUi] Space the create and update forms from the page header - #401

Closed
SVillette wants to merge 1 commit into
Sylius:mainfrom
SVillette:fix-bootstrap-admin-ui-form-spacing
Closed

SVillette wants to merge 1 commit into
Sylius:mainfrom
SVillette:fix-bootstrap-admin-ui-form-spacing

Conversation

@SVillette

@SVillette SVillette commented Nov 2, 2026 •

Copy link
Copy Markdown

On create and update pages, the form card sits flush against the page header: the bottom of the "Cancel" / "Create" buttons touches the card's top border.

The form's .container-xl follows .page-header with no margin. The .card-body wrapping the form looks like it should add spacing, but it is not inside a .card, so --tblr-card-spacer-y is undefined there and its padding resolves to 0. Index pages don't have the problem because grid.html.twig wraps the grid in .page-body, whose top margin is --tblr-page-padding-y.

This PR:

  • wraps the form in .page-body, like the index grid. The component attributes move to that new root element, so TalkFormComponent and other live forms keep a single root;
  • gives the form error alert container mt-4 and the alert mb-0. .page-wrapper is a flex column, so margins don't collapse; without this, the alert would still touch the header and sit 40px above the form;
  • compares the form validity strictly in the alert (is same as(false) rather than == false). === would need Twig 3.23, and the bundle still allows Twig 2.15.

Valid form

Before

image

After

image

Invalid form (error alert)

Before

image

After

image

Measured gaps:

State Before After
Valid form: header → card 0px 24px
Invalid form: header → alert 0px 24px
Invalid form: alert → card 16px 24px

No SCSS change, so public/app.css is not rebuilt. Functional tests select the alert by [data-test-form-error-alert], which is unchanged.

The markup changes, so an app that overrides only form_error_alert keeps an alert that touches the header and gets a 40px gap above the form, and an app that patched the gap with CSS such as .page-header + .container-xl now applies it to the alert alone.

🤖 Generated with Claude Code

…age header

The form's container followed .page-header with no margin, so the form
card touched the header's action buttons. Its .card-body wrapper has no
padding outside a .card, where --tblr-card-spacer-y is undefined.

Wrap the form in .page-body like the index grid, and give the form error
alert the same top margin so every gap is the page padding. The alert
also compares the form validity strictly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@loic425

loic425 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

@SVillette Thx for your proposal, I need to check the difference between Sylius admin and your changes on this PR first.

@loic425

loic425 commented Nov 23, 2026

Copy link
Copy Markdown
Member

Thanks a lot for the fix and the detailed write-up, the measurements made the problem very clear!

We're closing this one in favor of #413. The Sylius admin already solves the same gap in CSS, with the same templates: its _layout.scss gives the page header a bottom padding (and makes it sticky with sticky-header.js). #413 ports both files as is, so the create/update forms get the same 24px gap without changing the markup of form.html.twig / form_error_alert.html.twig.

We'd like to keep BootstrapAdminUi as close as possible to the Sylius admin templates and styles, since we'll probably merge them at some point. Once the sticky header is in, the .page-body wrapper and the mt-4 on the alert would also add up with the header padding (around 48px above the error alert).

@loic425 loic425 closed this Nov 23, 2026
TheMilek added a commit that referenced this pull request Nov 23, 2026
| Q               | A
|-----------------|-----
| Branch?         | main
| Bug fix?        | yes
| New feature?    | no
| BC breaks?      | no
| License         | MIT

On create and update pages, the form card is glued to the page header:
the "Cancel" / "Update" buttons touch the card. The header has no bottom
padding, and only the index pages render a `.page-body` with a top
margin.

The Sylius admin solves it in CSS, with the same templates. This PR
ports its `_layout.scss` and `sticky-header.js` as is (a follow-up
listed in #404):

- `.page-header` gets the page vertical padding, `.page-body` no longer
adds its own margin: same 24px gap on every page;
- the header sticks to the top while scrolling (border and shadow once
stuck), so the form buttons stay visible. The header template already
had the `data-sticky-header` attribute;
- no template or hook change.

Measured on the demo, talk edit page: header → card 0px before, 24px
after. Invalid form: header → alert 24px, alert → card 16px, as in
Sylius. Index pages are unchanged (24px).

It keeps BootstrapAdminUi closer to the Sylius admin templates and
styles, which should be merged at some point. It is an alternative to
#401 and #375, which fix the same gap by changing the markup or the
hooks.

`public/` assets were rebuilt with `yarn build`.

### Screenshots

Talk edit page of the demo application, default theme.

#### Valid form

<img width="1640" height="433" alt="valid-form"
src="https://github.com/user-attachments/assets/63444b42-6050-4d73-aebc-d4bfb032ac34"
/>

#### Invalid form

<img width="1640" height="433" alt="invalid-form"
src="https://github.com/user-attachments/assets/de5810fa-b79c-4451-ae83-a896b8850430"
/>

#### Sticky header, after scrolling

<img width="800" height="387" alt="sticky-header"
src="https://github.com/user-attachments/assets/4c8c125e-53aa-4a27-855e-a12df9ee5c01"
/>
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.

2 participants