fix: tooltip overflow (#269)

* fix: tooltip overflow

* Adds more responsive Css

* StartHidden has tooltip bottom

* in debug setting too

---------

Co-authored-by: CJ Pais <cj@cjpais.com>
This commit is contained in:
Piyush Gupta 2025-10-30 20:36:44 +05:30 committed by GitHub
parent 64ff385423
commit 951283ca8a
5 changed files with 34 additions and 27 deletions

View file

@ -273,6 +273,7 @@ export const HandyShortcut: React.FC<HandyShortcutProps> = ({
description="Set the keyboard shortcut to start and stop speech-to-text recording" description="Set the keyboard shortcut to start and stop speech-to-text recording"
descriptionMode={descriptionMode} descriptionMode={descriptionMode}
grouped={grouped} grouped={grouped}
tooltipPosition="bottom"
> >
{(() => { {(() => {
const primaryBinding = Object.values(bindings)[0]; const primaryBinding = Object.values(bindings)[0];

View file

@ -14,10 +14,8 @@ const pasteMethodOptions = [
{ value: "direct", label: "Direct" }, { value: "direct", label: "Direct" },
]; ];
export const PasteMethodSetting: React.FC<PasteMethodProps> = React.memo(({ export const PasteMethodSetting: React.FC<PasteMethodProps> = React.memo(
descriptionMode = "tooltip", ({ descriptionMode = "tooltip", grouped = false }) => {
grouped = false,
}) => {
const { getSetting, updateSetting, isUpdating } = useSettings(); const { getSetting, updateSetting, isUpdating } = useSettings();
const selectedMethod = (getSetting("paste_method") || const selectedMethod = (getSetting("paste_method") ||
@ -29,6 +27,7 @@ export const PasteMethodSetting: React.FC<PasteMethodProps> = React.memo(({
description="Clipboard (Ctrl+V) simulates Ctrl/Cmd+V keystrokes to paste from your clipboard. Direct tries to use system input methods if possible, otherwise inputs keystrokes one by one into the text field." description="Clipboard (Ctrl+V) simulates Ctrl/Cmd+V keystrokes to paste from your clipboard. Direct tries to use system input methods if possible, otherwise inputs keystrokes one by one into the text field."
descriptionMode={descriptionMode} descriptionMode={descriptionMode}
grouped={grouped} grouped={grouped}
tooltipPosition="bottom"
> >
<Dropdown <Dropdown
options={pasteMethodOptions} options={pasteMethodOptions}
@ -40,4 +39,5 @@ export const PasteMethodSetting: React.FC<PasteMethodProps> = React.memo(({
/> />
</SettingContainer> </SettingContainer>
); );
}); },
);

View file

@ -24,6 +24,7 @@ export const StartHidden: React.FC<StartHiddenProps> = React.memo(({
description="Launch to system tray without opening the window." description="Launch to system tray without opening the window."
descriptionMode={descriptionMode} descriptionMode={descriptionMode}
grouped={grouped} grouped={grouped}
tooltipPosition="bottom"
/> />
); );
}); });

View file

@ -8,6 +8,7 @@ interface SettingContainerProps {
grouped?: boolean; grouped?: boolean;
layout?: "horizontal" | "stacked"; layout?: "horizontal" | "stacked";
disabled?: boolean; disabled?: boolean;
tooltipPosition?: "top" | "bottom";
} }
export const SettingContainer: React.FC<SettingContainerProps> = ({ export const SettingContainer: React.FC<SettingContainerProps> = ({
@ -18,6 +19,7 @@ export const SettingContainer: React.FC<SettingContainerProps> = ({
grouped = false, grouped = false,
layout = "horizontal", layout = "horizontal",
disabled = false, disabled = false,
tooltipPosition = "top",
}) => { }) => {
const [showTooltip, setShowTooltip] = useState(false); const [showTooltip, setShowTooltip] = useState(false);
const tooltipRef = useRef<HTMLDivElement>(null); const tooltipRef = useRef<HTMLDivElement>(null);
@ -162,11 +164,11 @@ export const SettingContainer: React.FC<SettingContainerProps> = ({
/> />
</svg> </svg>
{showTooltip && ( {showTooltip && (
<div className="absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-background border border-mid-gray/80 rounded-lg shadow-lg z-50 max-w-xs min-w-[200px] whitespace-normal animate-in fade-in-0 zoom-in-95 duration-200"> <div className={`absolute ${tooltipPosition === "top" ? "bottom-full" : "top-[150%]"} left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-background border border-mid-gray/80 rounded-lg shadow-lg z-50 max-w-xs min-w-[200px] whitespace-normal animate-in fade-in-0 zoom-in-95 duration-200`}>
<p className="text-sm text-center leading-relaxed"> <p className="text-sm text-center leading-relaxed">
{description} {description}
</p> </p>
<div className="absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-[6px] border-r-[6px] border-t-[6px] border-l-transparent border-r-transparent border-t-mid-gray/80"></div> <div className={`absolute ${tooltipPosition === "top" ? "top-full" : "bottom-full rotate-180"} left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-[6px] border-r-[6px] border-t-[6px] border-l-transparent border-r-transparent border-t-mid-gray/80`}></div>
</div> </div>
)} )}
</div> </div>

View file

@ -10,6 +10,7 @@ interface ToggleSwitchProps {
description: string; description: string;
descriptionMode?: "inline" | "tooltip"; descriptionMode?: "inline" | "tooltip";
grouped?: boolean; grouped?: boolean;
tooltipPosition?: "top" | "bottom";
} }
export const ToggleSwitch: React.FC<ToggleSwitchProps> = ({ export const ToggleSwitch: React.FC<ToggleSwitchProps> = ({
@ -21,6 +22,7 @@ export const ToggleSwitch: React.FC<ToggleSwitchProps> = ({
description, description,
descriptionMode = "tooltip", descriptionMode = "tooltip",
grouped = false, grouped = false,
tooltipPosition = "top",
}) => { }) => {
return ( return (
<SettingContainer <SettingContainer
@ -29,6 +31,7 @@ export const ToggleSwitch: React.FC<ToggleSwitchProps> = ({
descriptionMode={descriptionMode} descriptionMode={descriptionMode}
grouped={grouped} grouped={grouped}
disabled={disabled} disabled={disabled}
tooltipPosition={tooltipPosition}
> >
<label <label
className={`inline-flex items-center ${disabled || isUpdating ? "cursor-not-allowed" : "cursor-pointer"}`} className={`inline-flex items-center ${disabled || isUpdating ? "cursor-not-allowed" : "cursor-pointer"}`}