Better handling of the close function

This commit is contained in:
Vladimir Borisov 2019-09-30 14:41:34 +03:00
parent 683acc77ef
commit 0c90e2d490
No known key found for this signature in database
GPG key ID: F9A584BE4FCB6603

View file

@ -22,23 +22,19 @@ const ColorInput = ({ className, value, onChange }) => {
}, [value, colorInputVisible]);
const modalBackgroundOnClick = React.useCallback((event) => {
if (!event.nativeEvent.preventClose) {
if(event.target === event.currentTarget) {
closeColorInput();
}
}, []);
const modalContentOnClick = React.useCallback((event) => {
event.nativeEvent.preventClose = true;
}, []);
return (
<React.Fragment>
<Button className={className} title={selectedColor} onClick={showColorInput} style={{ backgroundColor: value }}></Button>
{
colorInputVisible
?
<Modal className={classnames(styles['color-input-modal'])} onClick={modalBackgroundOnClick}>
<div className={classnames(styles['color-input-container'])} onClick={modalContentOnClick}>
<Modal className={styles['color-input-modal']} onMouseDown={modalBackgroundOnClick}>
<div className={styles['color-input-container']}>
<Button onClick={closeColorInput}>
<Icon className={classnames(styles['x-icon'])} icon={'ic_x'} />
</Button>