design-system-react icon indicating copy to clipboard operation
design-system-react copied to clipboard

Implement isOpen for Dropdown

Open interactivellama opened this issue 10 years ago • 4 comments

forceOpen was implemented to get around the constraints of Drop/TetherJS which say that any click on the screen closes the dropdown menu. This prevents inspecting the menu HTML contents, since it closes when clicked and when the Browser DevTools are clicked.

There may be a similar and better pattern on controlled/uncontrolled components. See React's docs on inputs and text areas.

interactivellama avatar Jul 18 '16 16:07 interactivellama

@tweettypography I'm not sure what you are referring to here. https://github.com/salesforce-ux/design-system-react/pull/428/files#r71095995

Do we just want to rename it to open? forceOpen makes dropdown a Controlled Component as per the FB React docs. Isn't that what you want to have?

Are you recommending something along the lines of an internal onChange, something like this that would affect user behavior (hover, click, etc)

handleChange: function(event) {
    this.setState({value: event.target.value});
  },

I believe the tricky part is that user interaction says to close on internal or outside click, so this can't be set via a default value, because then it would close on inspection, etc.

interactivellama avatar Jul 18 '16 16:07 interactivellama

What I meant was, if the app passes isOpen as a prop then that prop should always be used, we should make sure appropriate events are thrown, and the app should be responsible for tracking state and updating it in response to the events. If the app doesn't pass that prop then we'll use the current behavior of tracking it internally. It's the same controlled/uncontrolled pattern.

tweettypography avatar Jul 18 '16 21:07 tweettypography

Working on a demo of the App Launcher with a dropdown before the modal. This would be helpful but isn't higher priority than non demo work.

swilliamset avatar Sep 08 '16 19:09 swilliamset

This may be needed to close dropdown when iframes are on the page. The best way to test this within this library would be to set open the dropdown and then tell a wrapping component to close it and see if it closes and can be re opened. (isOpen would need to be set back to null though to allow user interactions once closed).

interactivellama avatar Sep 12 '16 16:09 interactivellama