Skip to content

feat: allow parent to dictate position when it has the position class#409

Open
thomasguillot wants to merge 5 commits intotrunkfrom
add/parent-overlay-position
Open

feat: allow parent to dictate position when it has the position class#409
thomasguillot wants to merge 5 commits intotrunkfrom
add/parent-overlay-position

Conversation

@thomasguillot
Copy link
Contributor

@thomasguillot thomasguillot commented Feb 4, 2026

All Submissions:

Changes proposed in this Pull Request:

This PR adds support for parent containers to --force an overlay’s position.

Specifically, when overlay content is included via a template part, such as the mobile menu, the parent template part wrapper can define a position class like overlay-contents--position--right--force. This overrides the position set within the overlay itself, allowing patterns to control the slide direction without modifying the shared template part.

This allows us to have multiple patterns (e.g. header) but still make sure the overlay comes from the correct side of the screen based on how buttons are organised.

How to test the changes in this Pull Request:

Note: Small screen is probably the easiest way to test so resize your screen

  1. Open your homepage and open the mobile menu. Notice it appears from the left as defined in parts/mobile-menu.html
  2. Switch to this branch
  3. In the editor, open your Header (mobile) and add a class of overlay-contents--position--right--force to the mobile-menu part, save
  4. Reload your homepage
  5. Notice now the menu opens from the right.
  6. Test this with --ful-width--force too
  7. Test if the search overlay still works (there was a small bug with the padding and was opened twice)

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Copy link
Contributor

@laurelfulford laurelfulford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works well on the front-end, @thomasguillot, but I get some weirdness in the editor:

When I add overlay-contents--position--right to the mobile menu template part -- this:

Image

The menu toggle moves to the right just in the editor:
Image

And when I add overlay-contents--position--full-width, it gets some extra spacing:

Image

Both work as described on the front-end, though, and I don't see any issues with the search.

These are both with Mobile pattern 2, but I saw the same thing with 1 (haven't tested 3). Am I just screwing up where to add the class? I checked the Mobile Menu Contents template part and there's not a parent container wrapping everything.

@thomasguillot
Copy link
Contributor Author

@laurelfulford I think it's because of the CSS (e.g. inset: 0 -100% 0 auto;). So instead of using the same class as the child, I introduced a --force option. This seems safer: .overlay-contents--position--{direction}--force.

So no CSS is applied in the editor. And the front-end still works. Let me know your thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants