dropdown
dropdown copied to clipboard
fix(Dropdown): visibility is controlled when undefined
Currently, react-component/dropdown checks the existance of the visibility key in props to determine whether or not the visibility prop is controlled or not. However, it should check for undefined instead. This will support the following behavior:
interface IMyDropdownWrapperProps {
myProp1: string;
visible?: boolean;
onVisibleChange?: (visible: boolean) => void;
}
const MyDropdownWrapper: React.FC<IMyDropdownWrapperProps > = ({
myProp1,
visible,
onVisibleChange
}) => {
return (
<Dropdown
// ISSUE: visible is now ALWAYS controlled, even though it may be undefined, which is not standard
visible={visible}
onVisibleChange={onVisibleChange}
>
My Dropdown
</Dropdown>
}
A workaround would be to use the spread operator or something similar to ensure that if visible is undefined, we don't pass down the visible key
Add a test case for this?
I modified an existing test case. Would you like me to create a separate case for this instead?
I modified an existing test case. Would you like me to create a separate case for this instead?
It's better to provide a separate case.
@MadCcc , I went ahead and created a separate case
rc-trigger is updated, you need to update your dependencies and run snapshot again.
I updated the minimum version for rc-trigger
, if that's what you meant by updating dependencies. Let me know if that's not what you meant
It will be a breaking change.
@afc163
Ah, good catch. I honestly didn't think about that. I assume package updates are handled separately, or do I bump the version as part of this CR? What would you like me to do from here to get this through, given that it's a breaking change?
Or do we want to push this off until later? I think it's important to add for consistency's sake, and users can employ workarounds.