Skip to content

Commit

Permalink
fix(web/menu): show values description without requiring button desc
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeWasTakenn committed Oct 30, 2022
1 parent 847f521 commit 765fff3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 0 additions & 1 deletion web/src/features/dev/debug/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const debugMenu = () => {
'pogchamp',
],
icon: 'tag',
description: 'Tooltip description 2',
},
{ label: 'Option 1' },
{ label: 'Option 2' },
Expand Down
13 changes: 11 additions & 2 deletions web/src/features/menu/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export interface MenuSettings {
startItemIndex?: number;
}

const isValuesObject = (values?: Array<string | { label: string; description: string }>) => {
return Array.isArray(values) && typeof values === 'object';
};

const ListMenu: React.FC = () => {
const [menu, setMenu] = useState<MenuSettings>({
position: 'top-left',
Expand Down Expand Up @@ -176,12 +180,17 @@ const ListMenu: React.FC = () => {
{visible && (
<Tooltip
label={
Array.isArray(menu.items[selected].values) && typeof menu.items[selected].values === 'object'
isValuesObject(menu.items[selected].values)
? // @ts-ignore
menu.items[selected].values[indexStates[selected]].description
: menu.items[selected].description
}
isOpen={!!menu.items[selected].description}
isOpen={
isValuesObject(menu.items[selected].values)
? // @ts-ignore
!!menu.items[selected].values[indexStates[selected]].description
: !!menu.items[selected].description
}
bg="#25262B"
color="#909296"
placement="bottom"
Expand Down

0 comments on commit 765fff3

Please sign in to comment.