Skip to content

Commit 69f4d16

Browse files
committed
use MenuButton in MenuFooter to be backwards compatible
1 parent da5a12a commit 69f4d16

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/components/Nav/Mobile/MenuFooter.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useTranslation } from "next-i18next"
22
import { BsTranslate } from "react-icons/bs"
33
import { MdBrightness2, MdSearch, MdWbSunny } from "react-icons/md"
4+
import { Button, ButtonProps, Icon, MenuButton } from "@chakra-ui/react"
45

56
import LanguagePicker from "@/components/LanguagePicker"
67

@@ -11,6 +12,17 @@ import FooterItemText from "./FooterItemText"
1112

1213
import useColorModeValue from "@/hooks/useColorModeValue"
1314

15+
/**
16+
* This is necessary to be backwards compatible with the old FooterButton
17+
* component where the ref was NOT passed to the Button component in order to
18+
* render the MenuList with an undefined position (not relative to the button).
19+
*
20+
* TODO: remove this component once the LanguagePicker component is migrated
21+
*/
22+
function ButtonWORef(props: ButtonProps) {
23+
return <Button {...props} />
24+
}
25+
1426
type MenuFooterProps = {
1527
onToggle: () => void
1628
toggleColorMode: () => void
@@ -57,9 +69,19 @@ const MenuFooter = ({
5769
opacity: 0.4,
5870
}} // TODO: Replace with overlay component
5971
>
60-
<FooterButton icon={BsTranslate} name={MOBILE_LANGUAGE_BUTTON_NAME}>
72+
<MenuButton
73+
as={ButtonWORef}
74+
name={MOBILE_LANGUAGE_BUTTON_NAME}
75+
leftIcon={<Icon as={BsTranslate} />}
76+
sx={{ span: { m: 0 } }}
77+
variant="ghost"
78+
flexDir="column"
79+
alignItems="center"
80+
color="body.base"
81+
px="1"
82+
>
6183
<FooterItemText>{t("languages")}</FooterItemText>
62-
</FooterButton>
84+
</MenuButton>
6385
</LanguagePicker>
6486
</div>
6587
)

0 commit comments

Comments
 (0)