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

[joy-ui][ButtonGroup] Using css pseudo selectors for button group styles #41456

Closed
wants to merge 1 commit into from
Closed

[joy-ui][ButtonGroup] Using css pseudo selectors for button group styles #41456

wants to merge 1 commit into from

Conversation

aacevski
Copy link
Contributor

Related issues: #39372 #40021

This is a proposal pull request which works and fixes the mentioned issues, using pseudo selectors works fine.

However is there a reason we use data-ids instead of pseudo selectors? If this is good, I will also update the tests.

@aacevski aacevski changed the title fix: Using css pseudo selectors for button group styles [joy-ui][Button Group] Using css pseudo selectors for button group styles Mar 11, 2024
@aacevski aacevski changed the title [joy-ui][Button Group] Using css pseudo selectors for button group styles [joy-ui][ButtonGroup] Using css pseudo selectors for button group styles Mar 11, 2024
@mui-bot
Copy link

mui-bot commented Mar 11, 2024

Netlify deploy preview

https://deploy-preview-41456--material-ui.netlify.app/

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 3ba397d

@siriwatknp
Copy link
Member

Related issues: #39372 #40021

This is a proposal pull request which works and fixes the mentioned issues, using pseudo selectors works fine.

However is there a reason we use data-ids instead of pseudo selectors? If this is good, I will also update the tests.

Really appreciate the PR.

The reason to use data-first-child is to make it work with zero-config SSR from emotion where <style> is inserted between elements.

<div>
  <style></style>
  <button></button>
  <style></style>
  <button></button>
  <style></style>
  <button></button>
</div>

I would not change anything at this point given we are focusing on Material UI v6. Open for other solutions as well.

@siriwatknp siriwatknp added the on hold There is a blocker, we need to wait label Mar 13, 2024
@aacevski
Copy link
Contributor Author

Related issues: #39372 #40021

This is a proposal pull request which works and fixes the mentioned issues, using pseudo selectors works fine.

However is there a reason we use data-ids instead of pseudo selectors? If this is good, I will also update the tests.

Really appreciate the PR.

The reason to use data-first-child is to make it work with zero-config SSR from emotion where <style> is inserted between elements.

<div>

  <style></style>

  <button></button>

  <style></style>

  <button></button>

  <style></style>

  <button></button>

</div>

I would not change anything at this point given we are focusing on Material UI v6. Open for other solutions as well.

Wouldn't button:first-of-type cover that use case?

@mnajdova
Copy link
Member

Wouldn't button:first-of-type cover that use case?

It wouldn't if the Button component is rendered as a different DOM node. We could use class name, but again custom components won't work. The data-first-child is a nice workaround, and easily applicable on custom components too. I would close the pull request as won't fix for now. At this moment we are focused on Material UI v6, which is mostly around converting the components to support CSS static extraction. I would recommend checking the umbrella issue #41273 if you are looking for things to contribute to. Thanks for the effort! :)

@aacevski
Copy link
Contributor Author

Wouldn't button:first-of-type cover that use case?

It wouldn't if the Button component is rendered as a different DOM node. We could use class name, but again custom components won't work. The data-first-child is a nice workaround, and easily applicable on custom components too. I would close the pull request as won't fix for now. At this moment we are focused on Material UI v6, which is mostly around converting the components to support CSS static extraction. I would recommend checking the umbrella issue #41273 if you are looking for things to contribute to. Thanks for the effort! :)

Thank you! I will look at the umbrella issue as you suggested, I would love to contribute! Will close this PR for now until I think of a better solution.

@aacevski aacevski closed this Mar 14, 2024
@aacevski aacevski deleted the fix/broken-styles-button-group branch March 17, 2024 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ButtonGroup The React component. on hold There is a blocker, we need to wait package: joy-ui Specific to @mui/joy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants