Skip to content

[BootstrapAdminUi] Add a body hookable to the create/update content composition - #375

Closed
vvasiloi wants to merge 1 commit into
Sylius:mainfrom
vvasiloi:fix/crud-form-page-body
Closed

vvasiloi wants to merge 1 commit into
Sylius:mainfrom
vvasiloi:fix/crud-form-page-body

Conversation

@vvasiloi

@vvasiloi vvasiloi commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Create/update pages render no .page-body, so the form card sits glued to the sticky page header — the header-to-content spacing in Tabler comes from .page-body's top margin against its .page-header sibling.

This adds a body hookable (rendering .page-body) to the create/update content composition; form_error_alert and form move under it.

BC break: hook customizations targeting sylius_admin.common.{create,update}.content.form* must retarget …content.body.form* — documented in the new UPGRADE.md.

Before After
before after

@vvasiloi
vvasiloi force-pushed the fix/crud-form-page-body branch 3 times, most recently from 5b8b084 to d11100e Compare July 12, 2026 16:45
@vvasiloi vvasiloi changed the title [BootstrapAdminUi] Wrap CRUD form content in .page-body like the index grid [BootstrapAdminUi] Add a body hookable to the create/update content composition Jul 12, 2026
@vvasiloi
vvasiloi force-pushed the fix/crud-form-page-body branch from d11100e to 9b6b7c3 Compare July 12, 2026 17:03
Tabler's header-to-content spacing comes from .page-body's top margin
against its .page-header sibling. The create/update pages render no
.page-body, so the form card sits glued to the sticky header.

BC break: form_error_alert and form move from …content.* to
…content.body.*.
@vvasiloi
vvasiloi force-pushed the fix/crud-form-page-body branch from 9b6b7c3 to bca6861 Compare July 12, 2026 17:09
@vvasiloi
vvasiloi marked this pull request as ready for review July 12, 2026 17:17
@vvasiloi

Copy link
Copy Markdown
Contributor Author

CI failures are unrelated: ^1.15@alpha now resolves sylius/grid-bundle to 1.16.0-RC.3 (Jul 10), whose GridBuilderInterface BC layer (conditional re-declaration + class_alias from the new Component namespace) trips DebugClassLoader during kernel boot — reproducible on unmodified main.

@loic425

loic425 commented Jul 22, 2026

Copy link
Copy Markdown
Member

@vvasiloi Thx for your proposal, on Sylius E-commerce how is it done?
But I'm in favour of your implementation.

@vvasiloi

Copy link
Copy Markdown
Contributor Author

@loic425 In Sylius e-commrece it's not done at all, at least not structurally. The shared sylius_admin.common.{create,update}.content composition is the same as here, and form.html.twig opens straight into .container-xl, without a .page-body:

https://github.com/Sylius/Sylius/blob/b7d3f8455ad06cf7c8b5bbb226cce898348c7222/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/common/create.yaml#L14-L31

Sylius proper fixes the visual bug via CSS in _layout.scss, by making the header sticky and zeroes .page-body's margin:

https://github.com/Sylius/Sylius/blob/b7d3f8455ad06cf7c8b5bbb226cce898348c7222/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_layout.scss#L10-L29

plus the sticky-header script that toggles .is-sticky:

https://github.com/Sylius/Sylius/blob/b7d3f8455ad06cf7c8b5bbb226cce898348c7222/src/Sylius/Bundle/AdminBundle/Resources/assets/scripts/sticky-header.js#L1-L12

So the header-to-content gap comes from the header's own padding-bottom , and Tabler's .page-body { margin-top } is deliberately zeroed so index/show pages don't double-space. Stack emits data-sticky-header in header.html.twig but ships neither the stylesheet nor the JS, so we inherit vanilla Tabler which has the sub-header gap only via .page-body's margin-top, which create/update never render. That's the actual root cause.

The only places Sylius emits .page-body on a form page are taxon and promotion coupon, and it's per-resource, not in the shared composition: they disable the shared form hookable and swap in a sections template…

https://github.com/Sylius/Sylius/blob/b7d3f8455ad06cf7c8b5bbb226cce898348c7222/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/taxon/create.yaml#L3-L8

…that opens the wrapper itself:

https://github.com/Sylius/Sylius/blob/b7d3f8455ad06cf7c8b5bbb226cce898348c7222/src/Sylius/Bundle/AdminBundle/templates/taxon/sections.html.twig#L1-L2

So the two fixes are alternatives, not complements. There are two ways forward:

  • Keep this hookable, meaning no extra CSS/JS, consistent .page-body across index/create/update, at the cost of the documented BC break.
  • Port _layout.scss + sticky-header.js instead, meaning no BC break, and the data-sticky-header the Stack emits would do something.

I lean towards the structural change beacuse it also makes more sense semantically.

@loic425

loic425 commented Nov 23, 2026

Copy link
Copy Markdown
Member

Thanks for tackling this and for documenting the BC break so carefully!

We're closing this one in favor of #413, which fixes the same gap without renaming any hook. The Sylius admin solves it in CSS: its _layout.scss gives the page header a bottom padding and makes it sticky (sticky-header.js). #413 ports both files as is, so the sylius_admin.common.{create,update}.content.form* hooks stay as they are and nothing needs to be retargeted.

We'd like to keep BootstrapAdminUi as close as possible to the Sylius admin templates and hooks, since we'll probably merge them at some point.

@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