dropdown icon indicating copy to clipboard operation
dropdown copied to clipboard

fix(Dropdown): visibility is controlled when undefined

Open C-Hess opened this issue 2 years ago • 8 comments

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

C-Hess avatar Mar 01 '22 17:03 C-Hess

Add a test case for this?

MadCcc avatar Apr 12 '22 04:04 MadCcc

I modified an existing test case. Would you like me to create a separate case for this instead?

C-Hess avatar Apr 12 '22 04:04 C-Hess

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 avatar Apr 12 '22 06:04 MadCcc

@MadCcc , I went ahead and created a separate case

C-Hess avatar Apr 13 '22 18:04 C-Hess

rc-trigger is updated, you need to update your dependencies and run snapshot again.

MadCcc avatar Apr 25 '22 15:04 MadCcc

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

C-Hess avatar Apr 28 '22 20:04 C-Hess

It will be a breaking change.

afc163 avatar Apr 29 '22 02:04 afc163

@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.

C-Hess avatar May 03 '22 15:05 C-Hess