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][Button] Disable text highlighting #41902

Merged
merged 3 commits into from
Apr 15, 2024

Conversation

mithun522
Copy link
Contributor

@mithun522 mithun522 commented Apr 15, 2024

Fixes #41899 Where the user can see the text of the button by highlighting it.
Added userSelect: 'none', to the buttonClasses.loading which doesn't allow the users to select the button while it is loading (edited)

Edited by ZeeshanTamboli: Add userSelect: none unconditionally to disable text highlighting (for both loading and disabled states).

Preview: https://deploy-preview-41902--material-ui.netlify.app/joy-ui/react-button/

@mui-bot
Copy link

mui-bot commented Apr 15, 2024

Netlify deploy preview

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

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 0063dfc

@mithun522 mithun522 changed the title Fix #41899 [joy-ui][Button] Fix #418998 Apr 15, 2024
@ZeeshanTamboli ZeeshanTamboli added bug 🐛 Something doesn't work component: button This is the name of the generic UI component, not the React module! package: joy-ui Specific to @mui/joy labels Apr 15, 2024
@ZeeshanTamboli ZeeshanTamboli changed the title [joy-ui][Button] Fix #418998 [joy-ui][Button] Disable text highlighting when loading is true Apr 15, 2024
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

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

@mithun522 Thanks for the pull request to fix it. If you check Material UI's loading button it adds userSelect: none to the base button.
Additionally, text can still be highlighted when the Joy UI button is disabled, as seen in this example: https://deploy-preview-41902--material-ui.netlify.app/joy-ui/react-button/#basics.

disabledbutton

So it's better to add the style unconditionally:

--- a/packages/mui-joy/src/Button/Button.tsx
+++ b/packages/mui-joy/src/Button/Button.tsx
@@ -139,6 +139,7 @@ export const getButtonStyles = ({
       border: 'none',
       backgroundColor: 'transparent',
       cursor: 'pointer',
+      userSelect: 'none',
       display: 'inline-flex',
       alignItems: 'center',
       justifyContent: 'center',

@mithun522
Copy link
Contributor Author

@ZeeshanTamboli Thanks for your suggestion. I have made the change and gave a commit. Thank you again.

@ZeeshanTamboli ZeeshanTamboli changed the title [joy-ui][Button] Disable text highlighting when loading is true [joy-ui][Button] Disable text highlighting Apr 15, 2024
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

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

Thanks.

@ZeeshanTamboli ZeeshanTamboli added the needs cherry-pick The PR should be cherry-picked to master after merge label Apr 15, 2024
@ZeeshanTamboli ZeeshanTamboli merged commit 621f43e into mui:next Apr 15, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: button This is the name of the generic UI component, not the React module! needs cherry-pick The PR should be cherry-picked to master after merge package: joy-ui Specific to @mui/joy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[joy-ui][Button] The user can see the text by highlighting when loading is true
3 participants