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] Fix list value of false or 0 (zero) text is incorrectly grey #34255

Merged
merged 2 commits into from Sep 12, 2022

Conversation

kushagra010
Copy link
Contributor

@kushagra010 kushagra010 commented Sep 9, 2022

@mui-bot
Copy link

mui-bot commented Sep 9, 2022

Details of bundle changes

Generated by 🚫 dangerJS against 65cdaab

Copy link

@neovirtual neovirtual left a comment

Choose a reason for hiding this comment

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

This should work in almost every scenario, but if ownerState.value happens to be an object with properties, those properties will be merged with the styles object and potentially overwrite something or even accidentally add a style, or it might trigger a warning or error elsewhere if the style object is validated because it contains invalid properties. It is very unlikely but possible. I would suggest something like: (ownerState.value === null || ownerState.value === undefined) && {
opacity: 'var(--Select-placeholderOpacity)',
}

@kushagra010
Copy link
Contributor Author

@neovirtual
I agree with the above scenario but I just realized, that there shouldn't be any case where we should do this based on value. If we consider the scenario raised by you in this issue, we should add opacity when either the value is null or undefined.

  1. For value=null
    The current functionality is to deselect all options if the value is null. And I don't think anyone would need to do something like this to select the option Null, also if this is done, then it will override the functionality to deselect all options and so the Null option will be selected.
const [value, setValue] = useState(0);
<Select value={value} onChange={(v) => setValue(v)}>
	<Option value={null}>Null</Option>
	<Option value={0}>Zero</Option>
</Select>
  1. For value=undefined
    According to current functionality, it will not select the option with a value equal to undefined. This means in the case below, you will not be able to select the Undefined option.
const [value, setValue] = useState(0);
<Select value={value} onChange={(v) => setValue(v)}>
	<Option value={undefined}>Undefined</Option>
	<Option value={0}>Zero</Option>
</Select>

@neovirtual
Copy link

neovirtual commented Sep 9, 2022

@kushagra010 It appears we are in agreement about applying the placeholderOpacity style based on checking for null or undefined value as opposed to using the javascript nullish coalescing operator (??). If the current value given to the Select component is 0 (zero) or false, it should highlight the corresponding list item. I have not checked whether that is working as expected and it was not the reason I opened this bug report, but nonetheless it is an important matter to look into. Thank you.

Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

👍 Thanks for your first contribution!

I'd love to hear your feedback about Joy UI. What do you like and what should be improved? let me know!

@ZeeshanTamboli ZeeshanTamboli added bug 🐛 Something doesn't work component: select This is the name of the generic UI component, not the React module! package: joy-ui Specific to @mui/joy labels Sep 12, 2022
@hbjORbj hbjORbj merged commit 61dddcd into mui:master Sep 12, 2022
daniel-rabe pushed a commit to daniel-rabe/material-ui that referenced this pull request Nov 29, 2022
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: select This is the name of the generic UI component, not the React module! package: joy-ui Specific to @mui/joy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Joy] List value of false or 0 (zero) text is incorrectly grey
6 participants