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

Unexpected margin removal in TypographyStylesProvider #7289

Open
2 tasks done
QuinnStraus opened this issue Dec 20, 2024 · 0 comments · May be fixed by #7290
Open
2 tasks done

Unexpected margin removal in TypographyStylesProvider #7289

QuinnStraus opened this issue Dec 20, 2024 · 0 comments · May be fixed by #7290

Comments

@QuinnStraus
Copy link
Contributor

Dependencies check up

  • I have verified that I use latest version of all @mantine/* packages

What version of @mantine/* packages do you have in package.json?

7.15.1

What package has an issue?

@mantine/core

What framework do you use?

Next.js

In which browsers you can reproduce the issue?

Chrome

Describe the bug

The TypographyStylesProvider contains the following css selectors

& :first-child {
  margin-top: 0;
}

& :last-child {
  margin-bottom: 0;
}

These impact all elements that are either first or last within their container within the provider, and override any margin set on the top or bottom of any elements using a single class selector, since these selectors have higher specificity. This creates some unexpected behavior and also creates some issues with eg. the spoiler component, which adds margin-bottom to the container when the show or hide buttons are visible.

If possible, include a link to a codesandbox with a minimal reproduction

https://codesandbox.io/p/sandbox/mantine-react-template-forked-c8hv6r

Possible fix

Removing the selectors from the TypographyStylesProvider css file would solve the problem. From looking through the css file, it seems like these styles were added to remove the margin added to some items by the provider if they are first or last (specifically ul, ol, headers, img, p, hr, pre, table, caption, and blockquote). Filtering by these tags therefore should solve the problem.

Self-service

  • I would be willing to implement a fix for this issue
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 a pull request may close this issue.

1 participant