π OpenHands: AI-Driven Development
fix: right-align action buttons in modals/dialogs (#520)
Hiep Le0e94c5a369ca
diff --git a/__tests__/components/backends/add-backend-modal.test.tsx b/__tests__/components/backends/add-backend-modal.test.tsxindex f2690f29bd..932b174fba 100644--- a/__tests__/components/backends/add-backend-modal.test.tsx+++ b/__tests__/components/backends/add-backend-modal.test.tsx@@ -29,21 +29,22 @@ afterEach(() => {});describe("AddBackendModal", () => {- it("renders Save (left) before Cancel (right) in a 2-column grid", () => {+ it("places Cancel before Save in the footer so the dominant action is the last focusable button", () => {+ // Arrange: render the modal so both footer buttons are mounted.renderWithProviders(<AddBackendModal onClose={vi.fn()} />);- const submit = screen.getByTestId("add-backend-submit");+ // Act: locate the two footer buttons.const cancel = screen.getByTestId("add-backend-cancel");- const row = submit.parentElement!;+ const submit = screen.getByTestId("add-backend-submit");- // Save comes before Cancel in DOM order β Save is on the left.- const orderTest = submit.compareDocumentPosition(cancel);- // Bit 4 = DOCUMENT_POSITION_FOLLOWING: cancel comes after submit.+ // Assert: Cancel precedes Save in DOM order β this is what governs+ // tab order and screen-reader reading order, so the dominant Save+ // action is the rightmost / last-reached button.// eslint-disable-next-line no-bitwise- expect(orderTest & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();-- // Equal-width via grid-cols-2: each column is exactly 50% of the row.- expect(row.className).toContain("grid-cols-2");+ expect(+ cancel.compareDocumentPosition(submit) &+ Node.DOCUMENT_POSITION_FOLLOWING,+ ).toBeTruthy();});it("disables submit until all fields are filled", async () => {diff --git a/__tests__/components/features/chat/open-repository-modal.test.tsx b/__tests__/components/features/chat/open-repository-modal.test.tsxindex 7b6ef43752..c2a74366b3 100644--- a/__tests__/components/features/chat/open-repository-modal.test.tsx+++ b/__tests__/components/features/chat/open-repository-modal.test.tsx@@ -160,6 +160,28 @@ describe("OpenRepositoryModal", () => {expect(screen.getByText("BUTTON$CANCEL")).toBeInTheDocument();});+ it("places Cancel before Launch in the footer so the dominant action is the last focusable button", () => {+ // Arrange: render the modal so both footer buttons are mounted.+ render(+ <OpenRepositoryModal+ isOpen={true}+ onClose={mockOnClose}+ onLaunch={mockOnLaunch}+ />,+ );++ // Act: locate both footer buttons.+ const cancel = screen.getByText("BUTTON$CANCEL");+ const launch = screen.getByText("BUTTON$LAUNCH");++ // Assert: Cancel precedes the dominant Launch action in DOM order.+ // eslint-disable-next-line no-bitwise+ expect(+ cancel.compareDocumentPosition(launch) &+ Node.DOCUMENT_POSITION_FOLLOWING,+ ).toBeTruthy();+ });+it("should disable Launch button when no repository or branch is selected", () => {render(<OpenRepositoryModaldiff --git a/__tests__/components/features/conversation-panel/confirm-delete-modal.test.tsx b/__tests__/components/features/conversation-panel/confirm-delete-modal.test.tsxindex a9245be855..bcd148c8ee 100644--- a/__tests__/components/features/conversation-panel/confirm-delete-modal.test.tsx+++ b/__tests__/components/features/conversation-panel/confirm-delete-modal.test.tsx@@ -41,4 +41,22 @@ describe("ConfirmDeleteModal", () => {screen.getByText("CONVERSATION$DELETE_WARNING"),).toBeInTheDocument();});++ it("places Cancel before Confirm in the footer so the dominant action is the last focusable button", () => {+ // Arrange: render the modal so both footer buttons are mounted.+ renderWithProviders(+ <ConfirmDeleteModal onConfirm={vi.fn()} onCancel={vi.fn()} />,+ );++ // Act: locate both footer buttons.+ const cancel = screen.getByText("BUTTON$CANCEL");+ const confirm = screen.getByText("ACTION$CONFIRM_DELETE");++ // Assert: Cancel precedes the dominant Confirm action in DOM order.+ // eslint-disable-next-line no-bitwise+ expect(+ cancel.compareDocumentPosition(confirm) &+ Node.DOCUMENT_POSITION_FOLLOWING,+ ).toBeTruthy();+ });});diff --git a/__tests__/components/features/mcp-page/install-server-modal.test.tsx b/__tests__/components/features/mcp-page/install-server-modal.test.tsxindex 49c70b4469..2d3fb7f1e8 100644--- a/__tests__/components/features/mcp-page/install-server-modal.test.tsx+++ b/__tests__/components/features/mcp-page/install-server-modal.test.tsx@@ -179,4 +179,22 @@ describe("InstallServerModal", () => {await waitFor(() => expect(saveSpy).toHaveBeenCalledTimes(1));});++ it("places Cancel before Install in the footer so the dominant action is the last focusable button", async () => {+ // Arrange: render with any marketplace entry so the footer is mounted.+ const slack = MCP_MARKETPLACE.find((e) => e.id === "slack")!;+ renderWith(<InstallServerModal entry={slack} onClose={vi.fn()} />);+ await screen.findByTestId("mcp-install-modal");++ // Act: locate both footer buttons.+ const cancel = screen.getByTestId("mcp-install-cancel");+ const submit = screen.getByTestId("mcp-install-submit");++ // Assert: Cancel precedes the dominant Install action in DOM order.+ // eslint-disable-next-line no-bitwise+ expect(+ cancel.compareDocumentPosition(submit) &+ Node.DOCUMENT_POSITION_FOLLOWING,+ ).toBeTruthy();+ });});diff --git a/__tests__/components/settings/llm-profiles/delete-profile-modal.test.tsx b/__tests__/components/settings/llm-profiles/delete-profile-modal.test.tsxindex 153bc8ee9b..c200b56842 100644--- a/__tests__/components/settings/llm-profiles/delete-profile-modal.test.tsx+++ b/__tests__/components/settings/llm-profiles/delete-profile-modal.test.tsx@@ -85,6 +85,22 @@ describe("DeleteProfileModal", () => {expect(screen.getByText("Cancel")).toBeInTheDocument();});+ it("places Cancel before Delete in the footer so the dominant action is the last focusable button", () => {+ // Arrange: render the modal so both footer buttons are mounted.+ renderModal(mockProfile);++ // Act: locate both footer buttons.+ const cancel = screen.getByText("Cancel");+ const danger = screen.getByTestId("delete-profile-confirm");++ // Assert: Cancel precedes the dominant Delete action in DOM order.+ // eslint-disable-next-line no-bitwise+ expect(+ cancel.compareDocumentPosition(danger) &+ Node.DOCUMENT_POSITION_FOLLOWING,+ ).toBeTruthy();+ });+it("calls onClose when Cancel is clicked", async () => {const user = userEvent.setup();const handleClose = vi.fn();diff --git a/__tests__/components/settings/llm-profiles/rename-profile-modal.test.tsx b/__tests__/components/settings/llm-profiles/rename-profile-modal.test.tsxindex 12dd4a40fc..f85508fbee 100644--- a/__tests__/components/settings/llm-profiles/rename-profile-modal.test.tsx+++ b/__tests__/components/settings/llm-profiles/rename-profile-modal.test.tsx@@ -92,6 +92,22 @@ describe("RenameProfileModal", () => {expect(screen.getByText("Cancel")).toBeInTheDocument();});+ it("places Cancel before Rename in the footer so the dominant action is the last focusable button", () => {+ // Arrange: render the modal so both footer buttons are mounted.+ renderModal(mockProfile);++ // Act: locate both footer buttons.+ const cancel = screen.getByText("Cancel");+ const submit = screen.getByTestId("rename-profile-submit");++ // Assert: Cancel precedes the dominant Rename action in DOM order.+ // eslint-disable-next-line no-bitwise+ expect(+ cancel.compareDocumentPosition(submit) &+ Node.DOCUMENT_POSITION_FOLLOWING,+ ).toBeTruthy();+ });+it("calls onClose when Cancel is clicked", async () => {const user = userEvent.setup();const handleClose = vi.fn();diff --git a/src/components/features/backends/backend-form-modal.tsx b/src/components/features/backends/backend-form-modal.tsxindex bdc9f5f055..d0d5309667 100644--- a/src/components/features/backends/backend-form-modal.tsx+++ b/src/components/features/backends/backend-form-modal.tsx@@ -462,25 +462,23 @@ export function BackendForm({{renderActions ? (renderActions({ canSubmit, testIdRoot })) : (- <div className="grid grid-cols-2 gap-2 mt-2 w-full">- <BrandButton- type="submit"- variant="primary"- isDisabled={!canSubmit}- testId={`${testIdRoot}-submit`}- className="w-full text-center"- >- {t(I18nKey.BACKEND$SAVE)}- </BrandButton>+ <div className="flex justify-end gap-2 mt-2 w-full"><BrandButtontype="button"variant="secondary"onClick={onSubmitted}testId={`${testIdRoot}-cancel`}- className="w-full text-center">{t(I18nKey.BUTTON$CANCEL)}</BrandButton>+ <BrandButton+ type="submit"+ variant="primary"+ isDisabled={!canSubmit}+ testId={`${testIdRoot}-submit`}+ >+ {t(I18nKey.BACKEND$SAVE)}+ </BrandButton></div>)}</form>diff --git a/src/components/features/backends/manage-backends-modal.tsx b/src/components/features/backends/manage-backends-modal.tsxindex d4b9f8cec0..dda7149f36 100644--- a/src/components/features/backends/manage-backends-modal.tsx+++ b/src/components/features/backends/manage-backends-modal.tsx@@ -177,7 +177,7 @@ export function ManageBackendsModal({ onClose }: ManageBackendsModalProps) {)}</div>- <div className="flex justify-between gap-2 px-5 py-3 border-t border-[var(--oh-border)]">+ <div className="flex justify-end gap-2 px-5 py-3 border-t border-[var(--oh-border)]"><BrandButtontype="button"variant="secondary"diff --git a/src/components/features/chat/open-repository-modal.tsx b/src/components/features/chat/open-repository-modal.tsxindex b69c7d776c..5af298269b 100644--- a/src/components/features/chat/open-repository-modal.tsx+++ b/src/components/features/chat/open-repository-modal.tsx@@ -143,26 +143,20 @@ export function OpenRepositoryModal({</div><div- className="flex flex-col gap-2 w-full"+ className="flex justify-end gap-2 w-full"onClick={(event) => event.stopPropagation()}>+ <BrandButton type="button" variant="secondary" onClick={handleClose}>+ {t(I18nKey.BUTTON$CANCEL)}+ </BrandButton><BrandButtontype="button"variant="primary"onClick={handleLaunch}- className="w-full"isDisabled={!canLaunch}>{t(I18nKey.BUTTON$LAUNCH)}</BrandButton>- <BrandButton- type="button"- variant="secondary"- onClick={handleClose}- className="w-full"- >- {t(I18nKey.BUTTON$CANCEL)}- </BrandButton></div></ModalBody></ModalBackdrop>diff --git a/src/components/features/conversation-panel/confirm-delete-modal.tsx b/src/components/features/conversation-panel/confirm-delete-modal.tsxindex ea9a1e4718..127fc75aed 100644--- a/src/components/features/conversation-panel/confirm-delete-modal.tsx+++ b/src/components/features/conversation-panel/confirm-delete-modal.tsx@@ -52,27 +52,25 @@ export function ConfirmDeleteModal({<BaseModalDescription>{confirmationMessage}</BaseModalDescription></div><div- className="flex flex-col gap-2 w-full"+ className="flex justify-end gap-2 w-full"onClick={(event) => event.stopPropagation()}>- <BrandButton- type="button"- variant="primary"- onClick={onConfirm}- className="w-full"- data-testid="confirm-button"- >- {t(I18nKey.ACTION$CONFIRM_DELETE)}- </BrandButton><BrandButtontype="button"variant="secondary"onClick={onCancel}- className="w-full"data-testid="cancel-button">{t(I18nKey.BUTTON$CANCEL)}</BrandButton>+ <BrandButton+ type="button"+ variant="primary"+ onClick={onConfirm}+ data-testid="confirm-button"+ >+ {t(I18nKey.ACTION$CONFIRM_DELETE)}+ </BrandButton></div></ModalBody></ModalBackdrop>diff --git a/src/components/features/conversation-panel/confirm-stop-modal.tsx b/src/components/features/conversation-panel/confirm-stop-modal.tsxindex efb5930b7a..f536fd532f 100644--- a/src/components/features/conversation-panel/confirm-stop-modal.tsx+++ b/src/components/features/conversation-panel/confirm-stop-modal.tsx@@ -31,27 +31,25 @@ export function ConfirmStopModal({/></div><div- className="flex flex-col gap-2 w-full"+ className="flex justify-end gap-2 w-full"onClick={(event) => event.stopPropagation()}>- <BrandButton- type="button"- variant="primary"- onClick={onConfirm}- className="w-full"- data-testid="confirm-button"- >- {t(I18nKey.ACTION$CONFIRM_CLOSE)}- </BrandButton><BrandButtontype="button"variant="secondary"onClick={onCancel}- className="w-full"data-testid="cancel-button">{t(I18nKey.BUTTON$CANCEL)}</BrandButton>+ <BrandButton+ type="button"+ variant="primary"+ onClick={onConfirm}+ data-testid="confirm-button"+ >+ {t(I18nKey.ACTION$CONFIRM_CLOSE)}+ </BrandButton></div></ModalBody></ModalBackdrop>diff --git a/src/components/features/conversation-panel/exit-conversation-modal.tsx b/src/components/features/conversation-panel/exit-conversation-modal.tsxindex 8bc6349327..08f9458e87 100644--- a/src/components/features/conversation-panel/exit-conversation-modal.tsx+++ b/src/components/features/conversation-panel/exit-conversation-modal.tsx@@ -22,16 +22,16 @@ export function ExitConversationModal({<ModalBackdrop onClose={onCancel}><ModalBody testID="confirm-new-conversation-modal"><BaseModalTitle title={t(I18nKey.CONVERSATION$EXIT_WARNING)} />- <div className="flex w-full gap-2">- <ModalButton- text={t(I18nKey.ACTION$CONFIRM)}- onClick={onConfirm}- className="bg-[#C63143] flex-1"- />+ <div className="flex w-full justify-end gap-2"><ModalButtontext={t(I18nKey.BUTTON$CANCEL)}onClick={onClose}- className="bg-tertiary flex-1"+ className="bg-tertiary"+ />+ <ModalButton+ text={t(I18nKey.ACTION$CONFIRM)}+ onClick={onConfirm}+ className="bg-[#C63143]"/></div></ModalBody>diff --git a/src/components/features/mcp-page/install-server-modal.tsx b/src/components/features/mcp-page/install-server-modal.tsxindex ec1f2e31dc..ff2ab10f28 100644--- a/src/components/features/mcp-page/install-server-modal.tsx+++ b/src/components/features/mcp-page/install-server-modal.tsx@@ -309,27 +309,25 @@ export function InstallServerModal({</p>)}- <div className="grid grid-cols-2 gap-2 mt-2">+ <div className="flex justify-end gap-2 mt-2">+ <BrandButton+ type="button"+ variant="secondary"+ onClick={onClose}+ testId="mcp-install-cancel"+ >+ {t(I18nKey.BUTTON$CANCEL)}+ </BrandButton><BrandButtontype="submit"variant="primary"isDisabled={isPending}testId="mcp-install-submit"- className="w-full text-center">{isPending? t(I18nKey.SETTINGS$SAVING): t(I18nKey.MCP$INSTALL_BUTTON)}</BrandButton>- <BrandButton- type="button"- variant="secondary"- onClick={onClose}- testId="mcp-install-cancel"- className="w-full text-center"- >- {t(I18nKey.BUTTON$CANCEL)}- </BrandButton></div></form></ModalBackdrop>diff --git a/src/components/features/onboarding/steps/check-backend-step.tsx b/src/components/features/onboarding/steps/check-backend-step.tsxindex 265ea10cc6..c3f00f686d 100644--- a/src/components/features/onboarding/steps/check-backend-step.tsx+++ b/src/components/features/onboarding/steps/check-backend-step.tsx@@ -106,7 +106,7 @@ export function CheckBackendStep({ onBack, onNext }: CheckBackendStepProps) {onSubmitted={() => {}}testIdRoot="onboarding-backend"renderActions={({ canSubmit, testIdRoot }) => (- <div className="sticky bottom-0 flex items-center justify-between gap-2 mt-2 bg-base-secondary pt-4 pb-7">+ <div className="sticky bottom-0 flex items-center justify-end gap-2 mt-2 bg-base-secondary pt-4 pb-7"><BrandButtontestId="onboarding-backend-back"type="button"@@ -115,25 +115,23 @@ export function CheckBackendStep({ onBack, onNext }: CheckBackendStepProps) {>{t(I18nKey.ONBOARDING$BACK)}</BrandButton>- <div className="flex gap-2">- <BrandButton- testId={`${testIdRoot}-submit`}- type="submit"- variant="secondary"- isDisabled={!canSubmit}- >- {t(I18nKey.BACKEND$SAVE)}- </BrandButton>- <BrandButton- testId="onboarding-backend-next"- type="button"- variant="primary"- isDisabled={isConnected !== true}- onClick={onNext}- >- {t(I18nKey.ONBOARDING$NEXT)}- </BrandButton>- </div>+ <BrandButton+ testId={`${testIdRoot}-submit`}+ type="submit"+ variant="secondary"+ isDisabled={!canSubmit}+ >+ {t(I18nKey.BACKEND$SAVE)}+ </BrandButton>+ <BrandButton+ testId="onboarding-backend-next"+ type="button"+ variant="primary"+ isDisabled={isConnected !== true}+ onClick={onNext}+ >+ {t(I18nKey.ONBOARDING$NEXT)}+ </BrandButton></div>)}/>diff --git a/src/components/features/onboarding/steps/say-hello-step.tsx b/src/components/features/onboarding/steps/say-hello-step.tsxindex 5ccf809ca0..f88ae6fc05 100644--- a/src/components/features/onboarding/steps/say-hello-step.tsx+++ b/src/components/features/onboarding/steps/say-hello-step.tsx@@ -78,7 +78,7 @@ export function SayHelloStep({ onBack, onLaunched }: SayHelloStepProps) {className="w-full rounded-xl border border-white/10 bg-base-secondary px-4 py-3 text-base text-white placeholder:text-[var(--oh-text-subtle)] focus:border-primary focus:outline-none disabled:opacity-60"/>- <div className="sticky bottom-0 flex items-center justify-between gap-2 bg-base-secondary pt-4 pb-7">+ <div className="sticky bottom-0 flex items-center justify-end gap-2 bg-base-secondary pt-4 pb-7"><BrandButtontestId="onboarding-hello-back"type="button"diff --git a/src/components/features/onboarding/steps/setup-llm-step.tsx b/src/components/features/onboarding/steps/setup-llm-step.tsxindex 9c9e507abf..fb403c8b10 100644--- a/src/components/features/onboarding/steps/setup-llm-step.tsx+++ b/src/components/features/onboarding/steps/setup-llm-step.tsx@@ -128,7 +128,7 @@ export function SetupLlmStep({ onBack, onNext }: SetupLlmStepProps) {/></div>- <div className="sticky bottom-0 flex items-center justify-between gap-2 bg-base-secondary pt-4 pb-7">+ <div className="sticky bottom-0 flex items-center justify-end gap-2 bg-base-secondary pt-4 pb-7"><BrandButtontestId="onboarding-llm-back"type="button"diff --git a/src/components/features/settings/api-key-modal-base.tsx b/src/components/features/settings/api-key-modal-base.tsxindex 0e8d48af38..710061b680 100644--- a/src/components/features/settings/api-key-modal-base.tsx+++ b/src/components/features/settings/api-key-modal-base.tsx@@ -86,7 +86,7 @@ export function ApiKeyModalBase({{title}</h3>{children}- <div className="w-full flex gap-2 mt-2">{footer}</div>+ <div className="w-full flex justify-end gap-2 mt-2">{footer}</div></div></ModalBackdrop>);diff --git a/src/components/features/settings/llm-profiles/delete-profile-modal.tsx b/src/components/features/settings/llm-profiles/delete-profile-modal.tsxindex 84a4460479..3b63845e6d 100644--- a/src/components/features/settings/llm-profiles/delete-profile-modal.tsx+++ b/src/components/features/settings/llm-profiles/delete-profile-modal.tsx@@ -49,11 +49,19 @@ export function DeleteProfileModal({const footer = (<>+ <BrandButton+ ref={cancelButtonRef}+ type="button"+ variant="tertiary"+ onClick={handleClose}+ isDisabled={deleteProfile.isPending}+ >+ {t(I18nKey.BUTTON$CANCEL)}+ </BrandButton><BrandButtontestId="delete-profile-confirm"type="button"variant="danger"- className="grow"onClick={handleDelete}isDisabled={deleteProfile.isPending}aria-busy={deleteProfile.isPending}@@ -67,16 +75,6 @@ export function DeleteProfileModal({t(I18nKey.BUTTON$DELETE))}</BrandButton>- <BrandButton- ref={cancelButtonRef}- type="button"- variant="tertiary"- className="grow"- onClick={handleClose}- isDisabled={deleteProfile.isPending}- >- {t(I18nKey.BUTTON$CANCEL)}- </BrandButton></>);diff --git a/src/components/features/settings/llm-profiles/rename-profile-modal.tsx b/src/components/features/settings/llm-profiles/rename-profile-modal.tsxindex 0e8be8db63..2127a20607 100644--- a/src/components/features/settings/llm-profiles/rename-profile-modal.tsx+++ b/src/components/features/settings/llm-profiles/rename-profile-modal.tsx@@ -68,11 +68,18 @@ export function RenameProfileModal({const footer = (<>+ <BrandButton+ type="button"+ variant="tertiary"+ onClick={handleClose}+ isDisabled={renameProfile.isPending}+ >+ {t(I18nKey.BUTTON$CANCEL)}+ </BrandButton><BrandButtontestId="rename-profile-submit"type="button"variant="primary"- className="grow"onClick={handleSubmit}isDisabled={renameProfile.isPending || !isValid}>@@ -82,15 +89,6 @@ export function RenameProfileModal({t(I18nKey.BUTTON$RENAME))}</BrandButton>- <BrandButton- type="button"- variant="tertiary"- className="grow"- onClick={handleClose}- isDisabled={renameProfile.isPending}- >- {t(I18nKey.BUTTON$CANCEL)}- </BrandButton></>);diff --git a/src/components/features/settings/mcp-settings/mcp-server-form.tsx b/src/components/features/settings/mcp-settings/mcp-server-form.tsxindex be95b23113..986105a27c 100644--- a/src/components/features/settings/mcp-settings/mcp-server-form.tsx+++ b/src/components/features/settings/mcp-settings/mcp-server-form.tsx@@ -408,7 +408,7 @@ export function MCPServerForm({</>)}- <div className="flex items-center gap-4">+ <div className="flex items-center justify-end gap-2 w-full"><BrandButtontestId="cancel-button"type="button"diff --git a/src/components/shared/modals/confirmation-modal.tsx b/src/components/shared/modals/confirmation-modal.tsxindex 5838006215..df5327ec34 100644--- a/src/components/shared/modals/confirmation-modal.tsx+++ b/src/components/shared/modals/confirmation-modal.tsx@@ -36,13 +36,12 @@ export function ConfirmationModal({className="bg-base-secondary p-4 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)]"><p>{text}</p>- <div className="w-full flex gap-2">+ <div className="w-full flex justify-end gap-2"><BrandButtontestId="cancel-button"type="button"onClick={onCancel}variant="secondary"- className="grow"isDisabled={isConfirming}>{t(I18nKey.BUTTON$CANCEL)}@@ -52,7 +51,6 @@ export function ConfirmationModal({type="button"onClick={onConfirm}variant="primary"- className="grow"isDisabled={isConfirming}>{t(I18nKey.BUTTON$CONFIRM)}