Skip to content

Build your personal knowledge base with Trilium Notes

fix(react/global_menu): menu layout on mobile

Elian Doran168ff90e389b
diff --git a/apps/client/src/widgets/react/Dropdown.tsx b/apps/client/src/widgets/react/Dropdown.tsx
index 91403b6224..08cdbfed09 100644
--- a/apps/client/src/widgets/react/Dropdown.tsx
+++ b/apps/client/src/widgets/react/Dropdown.tsx
@@ -80,13 +80,13 @@ export default function Dropdown({ className, buttonClassName, isStatic, childre
<span className="caret"></span>
</button>
- <div
+ <ul
class={`dropdown-menu ${isStatic ? "static" : ""} ${dropdownContainerClassName ?? ""} tn-dropdown-list`}
style={dropdownContainerStyle}
aria-labelledby={ariaId}
>
{shown && children}
- </div>
+ </ul>
</div>
)
}
\ No newline at end of file
diff --git a/apps/client/src/widgets/react/FormList.tsx b/apps/client/src/widgets/react/FormList.tsx
index fb53186319..8991dea002 100644
--- a/apps/client/src/widgets/react/FormList.tsx
+++ b/apps/client/src/widgets/react/FormList.tsx
@@ -97,8 +97,8 @@ const TOOLTIP_CONFIG: Partial<Tooltip.Options> = {
fallbackPlacements: [ "right" ]
}
-export function FormListItem({ className, children, icon, value, title, active, badges, disabled, checked, onClick, description, selected, rtl, triggerCommand, outsideChildren }: FormListItemOpts) {
- const itemRef = useRef<HTMLAnchorElement>(null);
+export function FormListItem({ className, icon, value, title, active, disabled, checked, onClick, selected, rtl, triggerCommand, outsideChildren, description, ...contentProps }: FormListItemOpts) {
+ const itemRef = useRef<HTMLLIElement>(null);
if (checked) {
icon = "bx bx-check";
@@ -107,7 +107,7 @@ export function FormListItem({ className, children, icon, value, title, active,
useStaticTooltip(itemRef, TOOLTIP_CONFIG);
return (
- <a
+ <li
ref={itemRef}
class={`dropdown-item ${active ? "active" : ""} ${disabled ? "disabled" : ""} ${selected ? "selected" : ""} ${className ?? ""}`}
data-value={value} title={title}
@@ -117,18 +117,28 @@ export function FormListItem({ className, children, icon, value, title, active,
dir={rtl ? "rtl" : undefined}
>
<Icon icon={icon} />&nbsp;
- <div>
- {children}
- {badges && badges.map(({ className, text }) => (
- <span className={`badge ${className ?? ""}`}>{text}</span>
- ))}
- {description && <div className="description">{description}</div>}
- </div>
+ {description ? (
+ <div>
+ <FormListContent description={description} {...contentProps} />
+ </div>
+ ) : (
+ <FormListContent description={description} {...contentProps} />
+ )}
{outsideChildren}
- </a>
+ </li>
);
}
+function FormListContent({ children, badges, description }: Pick<FormListItemOpts, "children" | "badges" | "description">) {
+ return <>
+ {children}
+ {badges && badges.map(({ className, text }) => (
+ <span className={`badge ${className ?? ""}`}>{text}</span>
+ ))}
+ {description && <div className="description">{description}</div>}
+ </>;
+}
+
interface FormListHeaderOpts {
text: string;
}