fix(launch_bar): bootstrap tooltip for dropdown

This commit is contained in:
Elian Doran 2025-12-05 12:06:53 +02:00
parent 237ffeff52
commit 3ad4ca3943
No known key found for this signature in database
2 changed files with 10 additions and 2 deletions

View File

@ -27,12 +27,15 @@ export function LaunchBarActionButton(props: Omit<ActionButtonProps, "className"
}
export function LaunchBarDropdownButton({ children, icon, ...props }: Pick<DropdownProps, "title" | "children" | "onShown" | "dropdownOptions" | "dropdownRef"> & { icon: string }) {
const { isHorizontalLayout } = useContext(LaunchBarContext);
return (
<Dropdown
className="right-dropdown-widget"
buttonClassName="right-dropdown-button launcher-button"
hideToggleArrow
text={<Icon icon={icon} />}
titlePosition={isHorizontalLayout ? "bottom" : "right"}
{...props}
>{children}</Dropdown>
)

View File

@ -2,7 +2,7 @@ import { Dropdown as BootstrapDropdown } from "bootstrap";
import { ComponentChildren, HTMLAttributes } from "preact";
import { CSSProperties, HTMLProps } from "preact/compat";
import { MutableRef, useCallback, useEffect, useRef, useState } from "preact/hooks";
import { useUniqueName } from "./hooks";
import { useStaticTooltip, useUniqueName } from "./hooks";
type DataAttributes = {
[key: `data-${string}`]: string | number | boolean | undefined;
@ -28,11 +28,16 @@ export interface DropdownProps extends Pick<HTMLProps<HTMLDivElement>, "id" | "c
onHidden?: () => void;
dropdownOptions?: Partial<BootstrapDropdown.Options>;
dropdownRef?: MutableRef<BootstrapDropdown | null>;
titlePosition?: "top" | "right" | "bottom" | "left";
}
export default function Dropdown({ id, className, buttonClassName, isStatic, children, title, text, dropdownContainerStyle, dropdownContainerClassName, hideToggleArrow, iconAction, disabled, noSelectButtonStyle, noDropdownListStyle, forceShown, onShown: externalOnShown, onHidden: externalOnHidden, dropdownOptions, buttonProps, dropdownRef }: DropdownProps) {
export default function Dropdown({ id, className, buttonClassName, isStatic, children, title, text, dropdownContainerStyle, dropdownContainerClassName, hideToggleArrow, iconAction, disabled, noSelectButtonStyle, noDropdownListStyle, forceShown, onShown: externalOnShown, onHidden: externalOnHidden, dropdownOptions, buttonProps, dropdownRef, titlePosition }: DropdownProps) {
const containerRef = useRef<HTMLDivElement | null>(null);
const triggerRef = useRef<HTMLButtonElement | null>(null);
useStaticTooltip(triggerRef, {
placement: titlePosition ?? "bottom",
fallbackPlacements: [ titlePosition ?? "bottom" ]
});
const [ shown, setShown ] = useState(false);