Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(modal)!: use fixed positioning on host to prevent Safari from clipping content in certain layouts #9545

Merged

Conversation

jcfranco
Copy link
Member

@jcfranco jcfranco commented Jun 8, 2024

Related Issue: #9416

Summary

This restores modal's host positioning to fixed to avoid a Safari bug that causes content to be clipped.

Note: screenshot test was not added for this scenario since our testing environment uses Chrome.

BREAKING CHANGE: This should not require changes, but we are including this in the breaking change release due to the different modal configurations that could be impacted by the default position change.

@jcfranco jcfranco added the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Jun 8, 2024
@github-actions github-actions bot added the bug Bug reports for broken functionality. Issues should include a reproduction of the bug. label Jun 8, 2024
@benelan benelan changed the base branch from main to dev June 10, 2024 09:06
@jcfranco jcfranco marked this pull request as ready for review June 11, 2024 16:51
@jcfranco jcfranco requested a review from a team as a code owner June 11, 2024 16:51
@jcfranco jcfranco requested a review from macandcheese June 11, 2024 16:52
* Conditional styles for when Modal is slotted in Shell
*/

.container.slotted-in-shell {
Copy link
Member

Choose a reason for hiding this comment

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

Are these no longer needed? if so, what about the class for slotted-in-shell? We can remove it if not necessary. I think there is a prop as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

At least based on screenshot tests and shallow, local testing, it doesn't look like these are needed anymore after the modal style tweaks. This could benefit from some additional testing too. cc @geospatialem

Good catch on the prop. I'll take a look. 👀

Copy link
Member Author

Choose a reason for hiding this comment

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

I managed to eliminate the prop by dynamically checking if the overflowing container is the document body.

Copy link
Contributor

@macandcheese macandcheese left a comment

Choose a reason for hiding this comment

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

Looks good - this could potentially have some impact on consumers because of the variety of ways Modals are placed on a page, would this be good to land in a major release due to the risk?

* Conditional styles for when Modal is slotted in Shell
*/

.container.slotted-in-shell {
Copy link
Contributor

Choose a reason for hiding this comment

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

We set these classes for Alert and Sheet as well in Shell. Should we change those components as well and remove the internal props we set for these?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think so. Once we successfully move modal to this pattern, we can look at doing the same for similar components.

Copy link
Member Author

Choose a reason for hiding this comment

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

Note for future reference: slottedInShell was renamed to embedded in #9778.

@@ -129,4 +129,8 @@ slot[name="panel-top"]::slotted(calcite-shell-center-row) {
inset: 0;
}

slot[name="modals"]::slotted(calcite-modal) {
position: absolute;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any way to confirm we don't need the pointer-events rule?

Copy link
Member Author

Choose a reason for hiding this comment

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

pointer-events: none are applied to the modal when closed. Once open, this is set to the default, so I think the shell-slotted override isn't necessary.

inset-0
flex
items-center
justify-center
overflow-y-hidden
opacity-0
z-overlay;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we confirm this overlay isn't needed in some complex slot / stack situations?

Copy link
Member Author

Choose a reason for hiding this comment

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

The overlay z-index is already applied on the host, so modals should already be on that layer. Do you have any examples of complex stacking we could use for testing?

* adds `@floating-ui/utils` dep
@jcfranco
Copy link
Member Author

Looks good - this could potentially have some impact on consumers because of the variety of ways Modals are placed on a page, would this be good to land in a major release due to the risk?

Yeah, I can see this being risky because of all the different modal configurations and changes going into this. Since the associated issue does have a workaround, we could consider this for v3. cc @geospatialem

Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity. Please close your PR if it is no longer relevant. Thank you for your contributions.

@github-actions github-actions bot added the Stale Issues or pull requests that have not had recent activity. label Jun 23, 2024
@github-actions github-actions bot removed the Stale Issues or pull requests that have not had recent activity. label Jul 19, 2024
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity. Please close your PR if it is no longer relevant. Thank you for your contributions.

@github-actions github-actions bot added the Stale Issues or pull requests that have not had recent activity. label Jul 29, 2024
@github-actions github-actions bot removed the Stale Issues or pull requests that have not had recent activity. label Nov 17, 2024
@@ -18,7 +18,7 @@
}

:host {
@apply absolute flex inset-0 opacity-0 z-overlay;
@apply fixed flex inset-0 opacity-0 z-overlay;
Copy link
Member

Choose a reason for hiding this comment

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

Would we need to do this for the dialog component as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

We're going to test drive this with modal first. If everything works out smoothly, we could apply to other components before 4.0 since it wouldn't be breaking (see #9545 (comment)).

@jcfranco jcfranco force-pushed the jcfranco/9416-change-modal-host-to-use-fixed-positioning branch from 34ec85b to 4d00d75 Compare November 18, 2024 18:50
@jcfranco jcfranco force-pushed the jcfranco/9416-change-modal-host-to-use-fixed-positioning branch from 4d00d75 to a96b827 Compare November 18, 2024 18:51
@jcfranco jcfranco added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Nov 19, 2024
@jcfranco
Copy link
Member Author

@macandcheese @driskull Care to take another look at this one?

@jcfranco jcfranco changed the title fix(modal): use fixed positioning on host to prevent Safari from clipping content in certain layouts fix(modal)!: use fixed positioning on host to prevent Safari from clipping content in certain layouts Nov 19, 2024
@jcfranco
Copy link
Member Author

Failing E2E test should be stabilized by #10748.

Copy link
Member

@driskull driskull left a comment

Choose a reason for hiding this comment

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

Code changes look good to me 👍

@macandcheese
Copy link
Contributor

Looks good 👍 - this Chromatic test seems to cover the case I was curious about - when Modal is slotted elsewhere and not page-level : https://6266d45509d7eb004aa254fb-xnausuyubl.chromatic.com/?path=/story/components-shell--slotted-modal-and-alert

@jcfranco jcfranco merged commit f950e28 into dev Nov 19, 2024
18 of 19 checks passed
@jcfranco jcfranco deleted the jcfranco/9416-change-modal-host-to-use-fixed-positioning branch November 19, 2024 19:54
alisonailea pushed a commit that referenced this pull request Nov 19, 2024
…pping content in certain layouts (#9545)

**Related Issue:** #9416

## Summary

This restores `modal`'s host positioning to `fixed` to avoid a [Safari
bug](https://bugs.webkit.org/show_bug.cgi?id=160953) that causes content
to be clipped.

**Note**: screenshot test was not added for this scenario since our
testing environment uses Chrome.

BREAKING CHANGE: This should not require changes, but we are including
this in the breaking change release due to the different modal
configurations that could be impacted by the default `position` change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug reports for broken functionality. Issues should include a reproduction of the bug. pr ready for visual snapshots Adding this label will run visual snapshot testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants