Skip to content

Commit 8900def

Browse files
Merge main into takeover/mobile-file-link-24620
2 parents 797798d + 44df336 commit 8900def

5 files changed

Lines changed: 63 additions & 53 deletions

File tree

‎apps/mobile/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
"react-native-enriched-markdown": "file:deps/react-native-enriched-markdown-1.2.0-t3.16-558767d9.tgz",
130130
"react-native-gesture-handler": "~3.3.0",
131131
"react-native-image-viewing": "^0.2.2",
132-
"react-native-keyboard-controller": "1.22.7",
132+
"react-native-keyboard-controller": "1.22.8",
133133
"react-native-nitro-modules": "0.37.1",
134134
"react-native-pdf-jsi": "5.0.0",
135135
"react-native-reanimated": "4.7.1",

‎apps/web/src/components/ComposerPromptEditorTiptap.input.browser.test.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { createElement, createRef, useEffect, useState } from "react";
1313
import { describe, expect, it, vi } from "vite-plus/test";
1414
import { userEvent } from "vite-plus/test/browser";
1515

16-
import { act, render } from "../../test/render";
16+
import { act, fakeTimers, render } from "../../test/render";
1717

1818
import { serializeEditorDoc } from "~/composer-rich-text-doc";
1919
import { isMacPlatform } from "~/lib/utils";
@@ -376,10 +376,14 @@ describe("composer context undo lifetime", () => {
376376

377377
describe("an Arabic line", () => {
378378
async function focusEnd(editor: Editor) {
379+
// ProseMirror rewrites the DOM caret 20ms after focus. Run that now, or it
380+
// can undo the first arrow key before ProseMirror reads the native move.
381+
using _timers = fakeTimers();
379382
await act(async () => {
380383
editor.commands.focus("end");
381384
});
382385
await vi.waitFor(() => expect(document.activeElement).toBe(editor.view.dom));
386+
vi.runOnlyPendingTimers();
383387
}
384388

385389
it("leaves inline code through its start with ArrowRight, which points back", async () => {
Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ index 6481228..0dc5dd1 100644
187187
padding,
188188
currentHeight,
189189
diff --git a/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js b/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js
190-
index 827436c..fe9f371 100644
190+
index 11e81a9..de39eac 100644
191191
--- a/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js
192192
+++ b/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js
193-
@@ -32,6 +32,8 @@ function useExtraContentPadding(options) {
193+
@@ -33,6 +33,8 @@ function useExtraContentPadding(options) {
194194
extraContentPadding,
195195
keyboardPadding,
196196
blankSpace,
@@ -199,7 +199,7 @@ index 827436c..fe9f371 100644
199199
scroll,
200200
layout,
201201
size,
202-
@@ -66,8 +68,8 @@ function useExtraContentPadding(options) {
202+
@@ -74,8 +76,8 @@ function useExtraContentPadding(options) {
203203
}
204204

205205
// Compute effective delta considering blankSpace floor
@@ -210,20 +210,24 @@ index 827436c..fe9f371 100644
210210
const effectiveDelta = currentTotal - previousTotal;
211211
if (effectiveDelta === 0) {
212212
// blankSpace absorbed the change
213-
@@ -86,13 +88,11 @@ function useExtraContentPadding(options) {
214-
const target = Math.max(scroll.value - effectiveDelta, -currentTotal);
215-
scrollToTarget(target);
213+
@@ -116,14 +118,15 @@ function useExtraContentPadding(options) {
214+
if (inverted) {
215+
target = Math.max(base - effectiveDelta, -currentTotal);
216216
} else {
217217
- const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, 0);
218-
- // Clamp at 0 as well: when the content is shorter than the viewport a
219-
- // shrinking padding makes `effectiveDelta` negative while `scroll.value`
220-
- // is already 0, so the target would go below the top of the content.
221-
- const target = Math.max(Math.min(scroll.value + effectiveDelta, maxScroll), 0);
222218
+ const minScroll = -adjustedStartInsetCompensation;
223219
+ const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, minScroll);
224-
+ const target = Math.max(minScroll, Math.min(scroll.value + effectiveDelta, maxScroll));
225-
scrollToTarget(target);
220+
221+
- // Clamp at 0 as well: when the content is shorter than the viewport a
222+
- // shrinking padding makes `effectiveDelta` negative while `base` is
223+
- // already 0, so the target would go below the top of the content.
224+
- target = Math.max(Math.min(base + effectiveDelta, maxScroll), 0);
225+
+ // Clamp at the top as well: when the content is shorter than the
226+
+ // viewport a shrinking padding makes `effectiveDelta` negative while
227+
+ // `base` is already at the top.
228+
+ target = Math.max(minScroll, Math.min(base + effectiveDelta, maxScroll));
226229
}
230+
scrollToTarget(target);
227231
- }, [inverted, keyboardLiftBehavior]);
228232
+ }, [inverted, keyboardLiftBehavior, adjustedInsetCompensation, adjustedStartInsetCompensation]);
229233
}
@@ -430,10 +434,10 @@ index 043b973..df5a408 100644
430434
padding,
431435
currentHeight,
432436
diff --git a/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js b/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js
433-
index 3c90439..9e7ebb6 100644
437+
index cdca47b..3ea3a7f 100644
434438
--- a/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js
435439
+++ b/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js
436-
@@ -26,6 +26,8 @@ function useExtraContentPadding(options) {
440+
@@ -27,6 +27,8 @@ function useExtraContentPadding(options) {
437441
extraContentPadding,
438442
keyboardPadding,
439443
blankSpace,
@@ -442,7 +446,7 @@ index 3c90439..9e7ebb6 100644
442446
scroll,
443447
layout,
444448
size,
445-
@@ -60,8 +62,8 @@ function useExtraContentPadding(options) {
449+
@@ -68,8 +70,8 @@ function useExtraContentPadding(options) {
446450
}
447451

448452
// Compute effective delta considering blankSpace floor
@@ -453,20 +457,24 @@ index 3c90439..9e7ebb6 100644
453457
const effectiveDelta = currentTotal - previousTotal;
454458
if (effectiveDelta === 0) {
455459
// blankSpace absorbed the change
456-
@@ -80,14 +82,12 @@ function useExtraContentPadding(options) {
457-
const target = Math.max(scroll.value - effectiveDelta, -currentTotal);
458-
scrollToTarget(target);
460+
@@ -110,15 +112,16 @@ function useExtraContentPadding(options) {
461+
if (inverted) {
462+
target = Math.max(base - effectiveDelta, -currentTotal);
459463
} else {
460464
- const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, 0);
461-
- // Clamp at 0 as well: when the content is shorter than the viewport a
462-
- // shrinking padding makes `effectiveDelta` negative while `scroll.value`
463-
- // is already 0, so the target would go below the top of the content.
464-
- const target = Math.max(Math.min(scroll.value + effectiveDelta, maxScroll), 0);
465465
+ const minScroll = -adjustedStartInsetCompensation;
466466
+ const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, minScroll);
467-
+ const target = Math.max(minScroll, Math.min(scroll.value + effectiveDelta, maxScroll));
468-
scrollToTarget(target);
467+
468+
- // Clamp at 0 as well: when the content is shorter than the viewport a
469+
- // shrinking padding makes `effectiveDelta` negative while `base` is
470+
- // already 0, so the target would go below the top of the content.
471+
- target = Math.max(Math.min(base + effectiveDelta, maxScroll), 0);
472+
+ // Clamp at the top as well: when the content is shorter than the
473+
+ // viewport a shrinking padding makes `effectiveDelta` negative while
474+
+ // `base` is already at the top.
475+
+ target = Math.max(minScroll, Math.min(base + effectiveDelta, maxScroll));
469476
}
477+
scrollToTarget(target);
470478
- }, [inverted, keyboardLiftBehavior]);
471479
+ }, [inverted, keyboardLiftBehavior, adjustedInsetCompensation, adjustedStartInsetCompensation]);
472480
}
@@ -823,10 +831,10 @@ index f89b7c8..02e0e19 100644
823831

824832
type UseChatKeyboardReturn = {
825833
diff --git a/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts b/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
826-
index e7584ed..dc653b0 100644
834+
index 99cc6c6..d883e76 100644
827835
--- a/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
828836
+++ b/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
829-
@@ -17,6 +17,10 @@ type UseExtraContentPaddingOptions = {
837+
@@ -18,6 +18,10 @@ type UseExtraContentPaddingOptions = {
830838
keyboardPadding: SharedValue<number>;
831839
/** Minimum inset floor — used to absorb keyboard and extraContentPadding changes. */
832840
blankSpace: SharedValue<number>;
@@ -837,7 +845,7 @@ index e7584ed..dc653b0 100644
837845
/** Current vertical scroll offset. */
838846
scroll: SharedValue<number>;
839847
/** Visible viewport dimensions. */
840-
@@ -52,6 +56,8 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
848+
@@ -53,6 +57,8 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
841849
extraContentPadding,
842850
keyboardPadding,
843851
blankSpace,
@@ -846,7 +854,7 @@ index e7584ed..dc653b0 100644
846854
scroll,
847855
layout,
848856
size,
849-
@@ -95,14 +101,12 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
857+
@@ -104,14 +110,12 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
850858
}
851859

852860
// Compute effective delta considering blankSpace floor
@@ -867,30 +875,28 @@ index e7584ed..dc653b0 100644
867875
const effectiveDelta = currentTotal - previousTotal;
868876

869877
if (effectiveDelta === 0) {
870-
@@ -135,22 +139,28 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
871-
872-
scrollToTarget(target);
878+
@@ -170,20 +174,26 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
879+
if (inverted) {
880+
target = Math.max(base - effectiveDelta, -currentTotal);
873881
} else {
874882
+ const minScroll = -adjustedStartInsetCompensation;
875883
const maxScroll = Math.max(
876884
size.value.height - layout.value.height + currentTotal,
877885
- 0,
878886
+ minScroll,
879887
);
888+
880889
- // Clamp at 0 as well: when the content is shorter than the viewport a
881-
- // shrinking padding makes `effectiveDelta` negative while `scroll.value`
882-
- // is already 0, so the target would go below the top of the content.
890+
- // shrinking padding makes `effectiveDelta` negative while `base` is
891+
- // already 0, so the target would go below the top of the content.
892+
- target = Math.max(Math.min(base + effectiveDelta, maxScroll), 0);
883893
+ // Clamp at the top as well: when the content is shorter than the
884894
+ // viewport a shrinking padding makes `effectiveDelta` negative while
885-
+ // `scroll.value` is already at the top.
886-
const target = Math.max(
887-
+ minScroll,
888-
Math.min(scroll.value + effectiveDelta, maxScroll),
889-
- 0,
890-
);
891-
892-
scrollToTarget(target);
895+
+ // `base` is already at the top.
896+
+ target = Math.max(minScroll, Math.min(base + effectiveDelta, maxScroll));
893897
}
898+
899+
scrollToTarget(target);
894900
},
895901
- [inverted, keyboardLiftBehavior],
896902
+ [

‎pnpm-lock.yaml‎

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-workspace.yaml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ minimumReleaseAgeExclude:
185185
186186
187187
188-
188+
189189
190190
191191
@@ -246,7 +246,7 @@ overrides:
246246
node-pty: 1.2.0-beta.15
247247
react-native-gesture-handler: 3.3.0
248248
react-native-reanimated: 4.7.1
249-
react-native-keyboard-controller: 1.22.7
249+
react-native-keyboard-controller: 1.22.8
250250
react-native-pdf-jsi: 5.0.0
251251
react-native-webview: 14.0.1
252252
"@expo/ui": 58.0.20
@@ -380,7 +380,7 @@ patchedDependencies:
380380
# Screens v5 stack, split and tab screens leave at once, like legacy screens. Exiting animations
381381
# inside one otherwise hold its removal for a later mount, after its stack has moved on.
382382
383-
383+
384384
385385
# Android: a nested WebView hands a vertical drag to its scrolling parent at the page's edge.
386386

0 commit comments

Comments
 (0)