Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .changeset/modal-keyboard-inset.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/modal-keyboard-safe-area.md

This file was deleted.

6 changes: 6 additions & 0 deletions .changeset/native-keyboard-reveal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"reshaped": patch
"@reshaped/utilities": patch
---

Page scroll lock on iOS and `Modal` leave revealing the focused field above the on-screen keyboard to the browser. Scroll lock no longer takes over focusing the pressed fields or puts back the page Safari panned for the keyboard, and `Modal` no longer ends above the keyboard. Both raced Safari's own panning, which moved the modal content around while focusing fields. `useVirtualKeyboard` stays available for positioning custom content above the keyboard
3 changes: 0 additions & 3 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@
"flyout-content-measuring",
"flyout-nested-outside-click",
"keyboard-mode-autofill",
"modal-keyboard-inset",
"modal-keyboard-safe-area",
"modal-swipe-gesture",
"overlay-ios-backdrop-scroll",
"overlay-ios-backdrop",
"overlay-open-latency",
"quiet-apples-wait",
"reviewed-prop-docs",
"scroll-lock-keyboard-pan",
"toast-provider-container-ref",
"touch-cancel-gestures",
"use-on-click-outside-capture",
Expand Down
6 changes: 0 additions & 6 deletions .changeset/scroll-lock-keyboard-pan.md

This file was deleted.

28 changes: 6 additions & 22 deletions packages/reshaped/src/components/Modal/Modal.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,14 @@
--rs-modal-container-height: 100vh;
--rs-modal-padding: calc(var(--rs-modal-p) * var(--rs-unit-x1));
--rs-modal-env-top: env(safe-area-inset-top, 0px);

/* iOS keeps reporting the bottom safe area while the on-screen keyboard covers it */
--rs-modal-env-bottom: max(
0px,
env(safe-area-inset-bottom, 0px) - var(--rs-modal-keyboard-height, 0px)
);
--rs-modal-env-bottom: env(safe-area-inset-bottom, 0px);
--rs-modal-env-start: env(safe-area-inset-left, 0px);
--rs-modal-env-end: env(safe-area-inset-right, 0px);

/**
* On-screen keyboard that doesn't resize the layout covers the bottom of the viewport,
* so the modals attached to the bottom edge end above it to keep their content reachable
*/
--rs-modal-keyboard: var(--rs-modal-keyboard-height, 0px);

/* Distance between the side modals and the screen edges, increased to the safe area insets when they're larger */
--rs-modal-offset: var(--rs-unit-x2);
--rs-modal-inset-top: max(var(--rs-modal-offset), var(--rs-modal-env-top));
--rs-modal-inset-bottom: calc(
max(var(--rs-modal-offset), var(--rs-modal-env-bottom)) + var(--rs-modal-keyboard)
);
--rs-modal-inset-bottom: max(var(--rs-modal-offset), var(--rs-modal-env-bottom));
--rs-modal-inset-start: max(var(--rs-modal-offset), var(--rs-modal-env-start));
--rs-modal-inset-end: max(var(--rs-modal-offset), var(--rs-modal-env-end));

Expand Down Expand Up @@ -96,7 +83,6 @@
--rs-modal-env-bottom: 0px;
--rs-modal-env-start: 0px;
--rs-modal-env-end: 0px;
--rs-modal-keyboard: 0px;
}
}

Expand Down Expand Up @@ -148,13 +134,11 @@
width: 100%;
height: var(--rs-modal-size);
max-width: 100%;
max-height: calc(
var(--rs-modal-container-height) - var(--rs-unit-x4) - var(--rs-modal-keyboard)
);
max-height: calc(var(--rs-modal-container-height) - var(--rs-unit-x4));
margin: 0;
margin-top: var(--rs-unit-x4);
inset: 0;
inset-block: auto var(--rs-modal-keyboard);
inset-block-start: initial;
transform: translate(0, 100%);
position: absolute;

Expand Down Expand Up @@ -245,12 +229,12 @@

box-shadow: var(--rs-modal-full-screen-shadow);
width: 100%;
height: calc(100% - var(--rs-modal-keyboard));
height: 100%;
max-width: var(--rs-modal-container-width);
max-height: 100%;
margin: 0;
inset: 0;
inset-block: auto var(--rs-modal-keyboard);
inset-block-start: initial;
transform: translate(0, var(--rs-unit-x4));
position: absolute;
border-width: 0;
Expand Down
3 changes: 0 additions & 3 deletions packages/reshaped/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Overlay, { type OverlayInstance } from "@/components/Overlay";
import Text from "@/components/Text";
import useElementId from "@/hooks/useElementId";
import useResponsiveClientValue from "@/hooks/useResponsiveClientValue";
import useVirtualKeyboard from "@/hooks/useVirtualKeyboard";
import { responsiveClassNames, responsiveVariables } from "@/utilities/props";
import type * as T from "./Modal.types";
import useModalDrag from "./useModalDrag";
Expand Down Expand Up @@ -79,7 +78,6 @@ const Modal: FC<T.Props> = (props) => {
} = props;
const id = useElementId();
const clientPosition = useResponsiveClientValue(position)!;
const keyboard = useVirtualKeyboard();
const [titleMounted, setTitleMounted] = useState(false);
const [subtitleMounted, setSubtitleMounted] = useState(false);
const internalRootRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -162,7 +160,6 @@ const Modal: FC<T.Props> = (props) => {
...responsiveVariables("--rs-modal-size", size),
...responsiveVariables("--rs-modal-p", padding),
"--rs-modal-drag": "0px",
"--rs-modal-keyboard-height": `${keyboard.height}px`,
} as React.CSSProperties
}
aria-labelledby={titleMounted ? `${id}-title` : undefined}
Expand Down
26 changes: 7 additions & 19 deletions packages/reshaped/src/components/Modal/tests/Modal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ describe("Components/Modal", () => {
await expect.element(page.getByTestId("test-id")).toHaveClass("test-classname");
});

test("test: virtual keyboard", async () => {
test("stays in place when the on-screen keyboard covers the viewport", async () => {
const Component = () => {
const { active, activate, deactivate } = useToggle();

Expand All @@ -237,36 +237,24 @@ describe("Components/Modal", () => {

const root = page.getByRole("dialog");
await expect.element(root).toBeInTheDocument();
const getKeyboardHeight = () =>
root.element().style.getPropertyValue("--rs-modal-keyboard-height");

const getBottomOffset = () =>
window.innerHeight - root.element().getBoundingClientRect().bottom;

expect(getKeyboardHeight()).toBe("0px");
const bottomOffset = getBottomOffset();
const getBottom = () => root.element().getBoundingClientRect().bottom;
const bottom = getBottom();

try {
// On-screen keyboard shrinks the visual viewport without changing the layout
// On-screen keyboard shrinks the visual viewport without changing the layout,
// and revealing the focused field above it is left to the browser
Object.defineProperty(viewport, "height", {
configurable: true,
value: window.innerHeight - 300,
});
viewport.dispatchEvent(new Event("resize"));
await new Promise(requestAnimationFrame);

// Bottom safe area inset is reduced by the keyboard height covering it
await expect.poll(getKeyboardHeight).toBe("300px");
// Modal ends above the keyboard with the same offset it has from the screen edge
expect(getBottomOffset()).toBe(bottomOffset + 300);
expect(getBottom()).toBe(bottom);
} finally {
// @ts-expect-error Removes the stubbed value from the viewport itself
delete viewport.height;
}

viewport.dispatchEvent(new Event("resize"));

await expect.poll(getKeyboardHeight).toBe("0px");
expect(getBottomOffset()).toBe(bottomOffset);
});

describe("swipe gesture", () => {
Expand Down
191 changes: 0 additions & 191 deletions packages/utilities/src/scroll/keyboardPan.ts

This file was deleted.

Loading
Loading