You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both Popover (coming soon) and Colorpicker use the same kind of logic so it'd be nice to extract into a common component.
Something like:
exportclassKuiClickOutsideToCloseextendsComponent{constructor(props){super(props);// Use this variable to differentiate between clicks on the element that should not cause the pop up// to close, and external clicks that should cause the pop up to close.this.didClickMyself=false;}onClickOutside=()=>{if(this.didClickMyself){this.didClickMyself=false;return;}this.props.onClickOutside();};onClickRootElement=()=>{// This prevents clicking on the element from closing it, due to the event handler on the// document object.this.didClickMyself=true;};componentDidMount(){// When the user clicks somewhere outside of the color picker, we will dismiss it.document.addEventListener('click',this.onClickOutside);}componentWillUnmount(){document.removeEventListener('click',this.onClickOutside);}render(){constprops=Object.assign({},this.props.children.props,{onClick: this.onClickRootElement,});returncloneElement(this.props.children,props);}}
Both Popover (coming soon) and Colorpicker use the same kind of logic so it'd be nice to extract into a common component.
Something like:
with usage like:
cc @cjcenizal
The text was updated successfully, but these errors were encountered: