From bf1e05fe1f72abfb80feec2ce6606d2e0cc4b159 Mon Sep 17 00:00:00 2001 From: Sean Ryan Date: Mon, 22 Apr 2024 20:11:33 -0700 Subject: [PATCH] Sean 4/22 Fixed render overlap of buttons and input fields in the CustomizationPanel component > > Co-author-by: Heather Pfeiffer Co-author-by: Jesse Wowczuk Co-author-by: Zack Vandiver Co-author-by: Sean Ryan Co-author-by: Austin Alvarez --- app/src/components/main/DeleteButton.tsx | 4 ++- app/src/containers/CustomizationPanel.tsx | 42 +++++++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/app/src/components/main/DeleteButton.tsx b/app/src/components/main/DeleteButton.tsx index 0a7d22e2..f9e5027a 100644 --- a/app/src/components/main/DeleteButton.tsx +++ b/app/src/components/main/DeleteButton.tsx @@ -34,7 +34,9 @@ function DeleteButton({ id, name, onClickHandler }: DeleteButtons) { id={'btn' + id} onClick={(event) => { event.stopPropagation(); - onClickHandler(event); + if (typeof onClickHandler === 'function') { + onClickHandler(event); + } deleteHTMLtype(id); }} > diff --git a/app/src/containers/CustomizationPanel.tsx b/app/src/containers/CustomizationPanel.tsx index e2263c04..49748638 100644 --- a/app/src/containers/CustomizationPanel.tsx +++ b/app/src/containers/CustomizationPanel.tsx @@ -56,6 +56,7 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => { const [flexDir, setFlexDir] = useState(''); const [flexJustify, setFlexJustify] = useState(''); const [flexAlign, setFlexAlign] = useState(''); + const [flexOptionsVisible, setFlexOptionsVisible] = useState(false); const [BGColor, setBGColor] = useState(''); const [compText, setCompText] = useState(''); const [compLink, setCompLink] = useState(''); @@ -69,7 +70,9 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => { const [useContextObj, setUseContextObj] = useState({}); const [stateUsedObj, setStateUsedObj] = useState({}); const [eventAll, setEventAll] = useState(['', '']); + const [eventOptionsVisible, setEventOptionsVisible] = useState(false); const [eventRow, setEventRow] = useState([]); + const [eventRowsVisible, setEventRowsVisible] = useState(false); const currFocus = getFocus().child; @@ -86,6 +89,35 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => { } }, [state]); + useEffect(() => { + if (displayMode === 'flex') { + return setFlexOptionsVisible(true); + } + return setFlexOptionsVisible(false); + }, [displayMode]); + + useEffect(() => { + if (eventAll[0] !== '') { + return setEventOptionsVisible(true); + } + return setEventOptionsVisible(false); + }, [eventAll]); + + useEffect(() => { + if (eventRow.length) { + return setEventRowsVisible(true); + } + return setEventRowsVisible(false); + }, [eventRow]); + + const marginTopAmount = () => { + let totalMargin = 0; + if (eventOptionsVisible) totalMargin += 90; + if (flexOptionsVisible) totalMargin = Math.max(totalMargin, 210); + if (eventRowsVisible) totalMargin = Math.max(totalMargin, 335); + return `${totalMargin}px`; + }; + //this function allows properties to persist and appear in nested divs function deepIterate(arr) { const output = []; @@ -128,7 +160,7 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => { resetFields(); }, [state.canvasFocus.componentId, state.canvasFocus.childId]); // handles all input field changes, with specific updates called based on input's name - const handleChange = (e: React.ChangeEvent<{ value: any }>) => { + const handleChange = (e: React.ChangeEvent) => { const inputVal = e.target.value; switch (e.target.name) { case 'display': @@ -862,7 +894,10 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => { )} -
+
)} -
+