π OpenHands: AI-Driven Development
fix(chat): keep confirmation button labels on one line (#18397)
Engel Nystaf68088f08f2
diff --git a/__tests__/components/shared/buttons/conversation-confirmation-buttons.test.tsx b/__tests__/components/shared/buttons/conversation-confirmation-buttons.test.tsxindex e1b54c7789..52e118c98c 100644--- a/__tests__/components/shared/buttons/conversation-confirmation-buttons.test.tsx+++ b/__tests__/components/shared/buttons/conversation-confirmation-buttons.test.tsx@@ -1,4 +1,4 @@-import { fireEvent, render, screen } from "@testing-library/react";+import { fireEvent, render, screen, within } from "@testing-library/react";import { afterEach, describe, expect, it, vi } from "vitest";import type { ReactNode } from "react";import { ConversationConfirmationButtons } from "#/components/shared/buttons/conversation-confirmation-buttons";@@ -360,12 +360,16 @@ describe("conversation confirmation controls", () => {</>,);- expect(screen.getByTestId("action-confirm-button")).toHaveTextContent(- `CHAT_INTERFACE$INPUT_CONTINUE_MESSAGE ${continueHint}`,- );- expect(screen.getByTestId("action-reject-button")).toHaveTextContent(- `BUTTON$CANCEL ${cancelHint}`,- );+ // The shortcut is its own element, not part of the label text, so the+ // label stays whole on narrow layouts that drop the hint.+ const confirm = within(screen.getByTestId("action-confirm-button"));+ expect(+ confirm.getByText("CHAT_INTERFACE$INPUT_CONTINUE_MESSAGE"),+ ).toBeInTheDocument();+ expect(confirm.getByText(continueHint)).toBeInTheDocument();+ const reject = within(screen.getByTestId("action-reject-button"));+ expect(reject.getByText("BUTTON$CANCEL")).toBeInTheDocument();+ expect(reject.getByText(cancelHint)).toBeInTheDocument();},);});diff --git a/src/components/shared/action-tooltip.tsx b/src/components/shared/action-tooltip.tsxindex 54f1587659..1c0ad71f72 100644--- a/src/components/shared/action-tooltip.tsx+++ b/src/components/shared/action-tooltip.tsx@@ -29,8 +29,9 @@ export function ActionTooltip({ type, onClick }: ActionTooltipProps) {const shortcutHint = SHORTCUT_HINTS[isApplePlatform() ? "apple" : "other"];const buttonLabel = isConfirm- ? `${t(I18nKey.CHAT_INTERFACE$INPUT_CONTINUE_MESSAGE)} ${shortcutHint.confirm}`- : `${t(I18nKey.BUTTON$CANCEL)} ${shortcutHint.reject}`;+ ? t(I18nKey.CHAT_INTERFACE$INPUT_CONTINUE_MESSAGE)+ : t(I18nKey.BUTTON$CANCEL);+ const buttonShortcut = isConfirm ? shortcutHint.confirm : shortcutHint.reject;return (<StyledTooltip closeDelay={100} content={content}>@@ -39,14 +40,16 @@ export function ActionTooltip({ type, onClick }: ActionTooltipProps) {type="button"aria-label={ariaLabel}className={cn(- "rounded px-2 h-6.5 text-sm font-normal leading-5 cursor-pointer hover:opacity-80",+ "inline-flex items-center gap-1 whitespace-nowrap rounded px-2 h-6.5 text-sm font-normal leading-5 cursor-pointer hover:opacity-80",type === "confirm"? "bg-tertiary text-contrast": "bg-contrast text-canvas-base",)}onClick={onClick}>- {buttonLabel}+ <span>{buttonLabel}</span>+ {/* Phones have no hardware keyboard and too little width for the hint. */}+ <span className="hidden sm:inline">{buttonShortcut}</span></button></StyledTooltip>);diff --git a/src/components/shared/buttons/conversation-confirmation-buttons.tsx b/src/components/shared/buttons/conversation-confirmation-buttons.tsxindex a0ff9ff88c..6680338400 100644--- a/src/components/shared/buttons/conversation-confirmation-buttons.tsx+++ b/src/components/shared/buttons/conversation-confirmation-buttons.tsx@@ -126,11 +126,11 @@ export function ConversationConfirmationButtons() {title={t(I18nKey.COMMON$HIGH_RISK)}/>)}- <div className="flex justify-between items-center">- <p className="text-sm font-normal text-contrast">+ <div className="flex justify-between items-center gap-3">+ <p className="min-w-0 text-sm font-normal text-contrast">{t(I18nKey.CHAT_INTERFACE$USER_ASK_CONFIRMATION)}</p>- <div className="flex items-center gap-3">+ <div className="flex shrink-0 items-center gap-3"><ActionTooltiptype="reject"onClick={() => handleConfirmation(false)}