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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

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.

@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
* 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
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. Stale Issues or pull requests that have not had recent activity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants