diff --git a/src/components/room/widgets/chat-input/ChatInputStyleSelectorView.tsx b/src/components/room/widgets/chat-input/ChatInputStyleSelectorView.tsx index b344404..0e02eed 100644 --- a/src/components/room/widgets/chat-input/ChatInputStyleSelectorView.tsx +++ b/src/components/room/widgets/chat-input/ChatInputStyleSelectorView.tsx @@ -1,85 +1,61 @@ -import { FC, MouseEvent, useEffect, useState } from 'react'; +import { FC, useState } from 'react'; import { ArrowContainer, Popover } from 'react-tiny-popover'; import { Flex, Grid, NitroCardContentView } from '../../../../common'; interface ChatInputStyleSelectorViewProps { - chatStyleId: number; - chatStyleIds: number[]; - selectChatStyleId: (styleId: number) => void; + chatStyleId: number; + chatStyleIds: number[]; + selectChatStyleId: (styleId: number) => void; } export const ChatInputStyleSelectorView: FC = props => { - const { chatStyleId = 0, chatStyleIds = null, selectChatStyleId = null } = props; - const [ target, setTarget ] = useState<(EventTarget & HTMLElement)>(null); - const [ selectorVisible, setSelectorVisible ] = useState(false); + const { chatStyleIds = null, selectChatStyleId = null } = props; + const [ selectorVisible, setSelectorVisible ] = useState(false); - const selectStyle = (styleId: number) => - { - selectChatStyleId(styleId); - setSelectorVisible(false); - }; + const selectStyle = (styleId: number) => + { + selectChatStyleId(styleId); + setSelectorVisible(false); + }; - const toggleSelector = (event: MouseEvent) => - { - let visible = false; - - setSelectorVisible(prevValue => - { - visible = !prevValue; - - return visible; - }); - - if(visible) setTarget((event.target as (EventTarget & HTMLElement))); - }; - - useEffect(() => - { - if(selectorVisible) return; - - setTarget(null); - }, [ selectorVisible ]); - - return ( - <> - - ( - - - - { chatStyleIds && (chatStyleIds.length > 0) && chatStyleIds.map((styleId) => - { - return ( - selectStyle(styleId) }> -
-
 
-
-
- ); - }) } -
-
- -
- ) } - isOpen={ selectorVisible } - positions={ [ 'top' ] } - > -
- - - - - ); -}; + return ( + ( + + + + {chatStyleIds && chatStyleIds.length > 0 && chatStyleIds.map(styleId => ( + selectStyle(styleId)}> +
+
 
+
+
+ ))} +
+
+
+ )} + > +
setSelectorVisible(v => !v)} + > +
+
+ + ); +}; \ No newline at end of file