Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: render telemetry consent banner above the onboarding modal (#1602)

Hiep Lea4abde8e903a
diff --git a/__tests__/components/shared/modals/modal-backdrop.test.tsx b/__tests__/components/shared/modals/modal-backdrop.test.tsx
index e251922187..672c50aadd 100644
--- a/__tests__/components/shared/modals/modal-backdrop.test.tsx
+++ b/__tests__/components/shared/modals/modal-backdrop.test.tsx
@@ -82,4 +82,32 @@ describe("ModalBackdrop", () => {
expect(onClose).not.toHaveBeenCalled();
});
+
+ it("stacks above the default modal layer when elevated", () => {
+ // Arrange: a default backdrop (the layer the onboarding modal uses) and an
+ // elevated backdrop (the layer the telemetry consent banner opts into).
+ render(
+ <>
+ <ModalBackdrop aria-label="default-modal">
+ <p>default modal</p>
+ </ModalBackdrop>
+ <ModalBackdrop elevated aria-label="elevated-modal">
+ <p>elevated modal</p>
+ </ModalBackdrop>
+ </>,
+ );
+
+ // Act: read the numeric stacking layer each modal renders on. jsdom cannot
+ // compute paint order, so compare the z-index the overlay carries.
+ const layerOf = (name: string) =>
+ Number(
+ screen
+ .getByRole("dialog", { name })
+ .className.match(/z-\[?(\d+)\]?/)?.[1] ?? 0,
+ );
+
+ // Assert: the elevated modal paints above the default one regardless of
+ // mount order, so the consent banner is never covered by the onboarding modal.
+ expect(layerOf("elevated-modal")).toBeGreaterThan(layerOf("default-modal"));
+ });
});
diff --git a/src/components/features/analytics/telemetry-consent-banner.tsx b/src/components/features/analytics/telemetry-consent-banner.tsx
index 89dbf8adf3..e463e8e518 100644
--- a/src/components/features/analytics/telemetry-consent-banner.tsx
+++ b/src/components/features/analytics/telemetry-consent-banner.tsx
@@ -76,7 +76,7 @@ export function TelemetryConsentBanner({
}
return (
- <ModalBackdrop aria-label={t(I18nKey.TELEMETRY$CONSENT_TITLE)}>
+ <ModalBackdrop elevated aria-label={t(I18nKey.TELEMETRY$CONSENT_TITLE)}>
<form
data-testid="telemetry-consent-form"
onSubmit={handleSubmit}
diff --git a/src/components/shared/modals/modal-backdrop.tsx b/src/components/shared/modals/modal-backdrop.tsx
index efd5d5f709..24229f9f61 100644
--- a/src/components/shared/modals/modal-backdrop.tsx
+++ b/src/components/shared/modals/modal-backdrop.tsx
@@ -8,6 +8,10 @@ interface ModalBackdropProps {
closeOnEscape?: boolean;
/** When false, clicking the backdrop does not close the modal. Defaults to true. */
closeOnBackdropClick?: boolean;
+ /** When true, renders above the default modal layer so it stacks over other
+ * modals (used by the telemetry consent banner over the onboarding modal).
+ * Defaults to false. */
+ elevated?: boolean;
"aria-label"?: string;
}
@@ -16,6 +20,7 @@ export function ModalBackdrop({
onClose,
closeOnEscape = true,
closeOnBackdropClick = true,
+ elevated = false,
"aria-label": ariaLabel,
}: ModalBackdropProps) {
React.useEffect(() => {
@@ -45,7 +50,9 @@ export function ModalBackdrop({
role="dialog"
aria-modal="true"
aria-label={ariaLabel}
- className="fixed inset-0 flex items-center justify-center z-60"
+ className={`fixed inset-0 flex items-center justify-center ${
+ elevated ? "z-[70]" : "z-60"
+ }`}
>
<div
onClick={handleClick}