Close icon dialog on icon selected.

This commit is contained in:
Paulo Gustavo Veiga 2022-10-31 20:10:10 -07:00
parent e0ce593102
commit 9b6dcdb923
2 changed files with 10 additions and 7 deletions

View File

@ -6,8 +6,9 @@ import NodeProperty from '../../../../../classes/model/node-property';
type IconImageTab = {
iconModel: NodeProperty;
triggerClose: () => void;
};
const IconImageTab = ({ iconModel }: IconImageTab) => {
const IconImageTab = ({ iconModel, triggerClose }: IconImageTab) => {
return (
<Box sx={{ width: '350px' }}>
{iconGroups.map((family, i) => (
@ -19,6 +20,7 @@ const IconImageTab = ({ iconModel }: IconImageTab) => {
src={SvgImageIcon.getImageUrl(icon)}
onClick={() => {
iconModel.setValue(`image:${icon}`);
triggerClose();
}}
></img>
))}

View File

@ -25,11 +25,11 @@ import FormGroup from '@mui/material/FormGroup';
import FormControlLabel from '@mui/material/FormControlLabel';
type IconPickerProp = {
closeModal: () => void;
triggerClose: () => void;
iconModel: NodeProperty;
};
const IconPicker = ({ closeModal, iconModel }: IconPickerProp) => {
const IconPicker = ({ triggerClose, iconModel }: IconPickerProp) => {
const [checked, setChecked] = React.useState(true);
const handleCheck = (event: React.ChangeEvent<HTMLInputElement>) => {
@ -39,14 +39,15 @@ const IconPicker = ({ closeModal, iconModel }: IconPickerProp) => {
// Review ...
useEffect(() => {
DesignerKeyboard.pause();
return () => { DesignerKeyboard.resume(); }
return () => {
DesignerKeyboard.resume();
};
}, []);
const handleEmojiSelect = (emoji: EmojiClickData) => {
const emojiChar = emoji.emoji;
iconModel.setValue(`emoji:${emojiChar}`);
closeModal();
triggerClose();
};
return (
@ -64,7 +65,7 @@ const IconPicker = ({ closeModal, iconModel }: IconPickerProp) => {
/>
)}
{!checked && <IconImageTab iconModel={iconModel} />}
{!checked && <IconImageTab iconModel={iconModel} triggerClose={triggerClose} />}
</div>
);
};