Skip to content

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 type: bug It doesn't behave as expected. scope: button Changes related to the button. package: joy-ui Specific to Joy UI. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs cherry-pick The PR should be cherry-picked to master after merge. package: joy-ui Specific to Joy UI. scope: button Changes related to the button. type: bug It doesn't behave as expected.

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