diff --git a/frontend/src/components/DropdownMenu.tsx b/frontend/src/components/DropdownMenu.tsx index 5e42c35..e848a0f 100644 --- a/frontend/src/components/DropdownMenu.tsx +++ b/frontend/src/components/DropdownMenu.tsx @@ -55,4 +55,4 @@ const dropdownStyle = (props: DropdownProps, backgroundColor: string) => { } } -export default DropdownMenu \ No newline at end of file +export default DropdownMenu diff --git a/frontend/src/components/ImageDropDown.tsx b/frontend/src/components/ImageDropDown.tsx index e047d23..38336f0 100644 --- a/frontend/src/components/ImageDropDown.tsx +++ b/frontend/src/components/ImageDropDown.tsx @@ -1,5 +1,5 @@ import React, {useState} from "react"; -import {colors, ListItemIcon, ListItemText, MenuItem, Select} from "@mui/material"; +import {ListItemText, MenuItem, Select} from "@mui/material"; import KeyboardDoubleArrowDownRoundedIcon from "@mui/icons-material/KeyboardDoubleArrowDownRounded"; import {ImageDropdownProps} from "../utilities/interfaces/ImageDropdownProps"; @@ -24,9 +24,11 @@ const ImageDropDown: React.FunctionComponent = (props: Image currentValue = e.target.value; props.localStorageItemKey ? localStorage.setItem(props.localStorageItemKey, currentValue) : gotImageURLs = gotImageURLs /* Do nothing */; currentIndex = props.values.indexOf(currentValue); - setText(props.texts[currentIndex]); + const currText = props.texts[currentIndex] + setText(currText); props.imageURLs ? setImageURL(props.imageURLs[currentIndex]) : setImageURL(""); props.colors ? setBackgroundColor(props.colors[currentIndex]) : setBackgroundColor(currentBackgroundColor); + props.onSelectionChange?.(currText, currentValue) } return ( @@ -34,15 +36,10 @@ const ImageDropDown: React.FunctionComponent = (props: Image sx={imageDropDownStyle(currentBackgroundColor)} IconComponent={KeyboardDoubleArrowDownRoundedIcon} onChange={handleChange} - value={props.texts} - renderValue={() => ( - - - - )} + value={currentValue} > - {props.texts.map((value) => ( - + {props.texts.map((value, index) => ( + ))} diff --git a/frontend/src/components/LoginBox.tsx b/frontend/src/components/LoginBox.tsx index 96ad4ff..06900ab 100644 --- a/frontend/src/components/LoginBox.tsx +++ b/frontend/src/components/LoginBox.tsx @@ -41,7 +41,7 @@ const LoginBox: React.FunctionComponent = () => { username: username, password: password, keepMeLoggedIn: stayLoggedIn, - }).then(navigateAfterLogin).catch(() => { + }).then(reloadPage).catch(() => { notification.error(localization.notificationMessage.incorrectLogin) }) } else { @@ -50,7 +50,7 @@ const LoginBox: React.FunctionComponent = () => { } } - const navigateAfterLogin = () => { + const reloadPage = () => { window.location.reload(); } @@ -64,6 +64,7 @@ const LoginBox: React.FunctionComponent = () => { imagesOnly={false} localStorageItemKey={localStorageItemKeys.selectedLanguage} defaultIndex={defaultLanguageIndex != -1 ? defaultLanguageIndex : 0} + onSelectionChange={reloadPage} /> diff --git a/frontend/src/utilities/interfaces/ImageDropdownProps.tsx b/frontend/src/utilities/interfaces/ImageDropdownProps.tsx index 60de9cf..7c89dce 100644 --- a/frontend/src/utilities/interfaces/ImageDropdownProps.tsx +++ b/frontend/src/utilities/interfaces/ImageDropdownProps.tsx @@ -39,4 +39,8 @@ export interface ImageDropdownProps { * Show images only (no text) */ imagesOnly?: boolean + /** + * Triggered whenever the selection changes + */ + onSelectionChange?: (text: string, value: string) => void } \ No newline at end of file