Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3eef060
Fix Workspace-In set approver page, member field hidden behind keypad
GCyganek Sep 28, 2026
0d49a7b
Fix Expense-Amount/merchant row hidden behind keypad in expense creat…
GCyganek Sep 28, 2026
4f48d7f
Fix Wallet - Search input in where's your bank account located is hid…
GCyganek Sep 28, 2026
e1ab3ca
Fix Spend-Search box is hidden behind keypad in spend page
GCyganek Sep 28, 2026
ea8c1d3
Fix Workspace-Remove fixed distance input hidden behind keypad
GCyganek Sep 28, 2026
307aaef
Fix tests
GCyganek Sep 29, 2026
db8c53f
add CollapsibleHeaderOnKeyboardGroupContext, use in IOURequestStartPage
GCyganek Sep 29, 2026
036f4d6
Merge branch 'main' into @GCyganek/landscape-mode/elements-hidden-beh…
GCyganek Sep 29, 2026
0c11e1e
Fix knip
GCyganek Sep 29, 2026
a3c83e8
Use Group and GroupMember on Spend page
GCyganek Sep 29, 2026
86d9d85
ApproverSelectionList move footer to list in landscape mode with keyb…
GCyganek Sep 29, 2026
3c028f5
Review feedback changes
GCyganek Sep 29, 2026
85975e0
Use Group and GroupMember for Wallet screens
GCyganek Sep 29, 2026
902cfc3
Fix comments
GCyganek Sep 29, 2026
90d0d6d
Merge branch 'main' into @GCyganek/landscape-mode/elements-hidden-beh…
GCyganek Oct 7, 2026
5aed8e6
Merge branch 'main' into @GCyganek/landscape-mode/elements-hidden-beh…
GCyganek Oct 8, 2026
d8985b1
Fix Card name input hidden behind keypad
GCyganek Oct 8, 2026
c16db88
Fix Card feed name input hidden behind keyboard
GCyganek Oct 8, 2026
efd9a45
Restore GH action bundles from main
GCyganek Oct 8, 2026
e3adf74
Delete console.log
GCyganek Oct 8, 2026
c313d12
BankAccountPuprosePage and CollectDepositAccount
GCyganek Oct 12, 2026
d9d579b
Merge branch 'main' into @GCyganek/landscape-mode/elements-hidden-beh…
GCyganek Oct 12, 2026
d8b2d95
Merge branch 'main' into @GCyganek/landscape-mode/elements-hidden-beh…
GCyganek Oct 12, 2026
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
16 changes: 11 additions & 5 deletions src/components/ApproverSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import useInitialSelection from '@hooks/useInitialSelection';
import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useShouldFooterBeInsideList from '@hooks/useShouldFooterBeInsideList';
import useThemeStyles from '@hooks/useThemeStyles';

import {canUseTouchScreen} from '@libs/DeviceCapabilities';
Expand All @@ -25,6 +26,7 @@ import type {ListItem} from './SelectionList/types';

import BlockingView from './BlockingViews/BlockingView';
import FullPageNotFoundView from './BlockingViews/FullPageNotFoundView';
import CollapsibleHeaderOnKeyboard from './CollapsibleHeaderOnKeyboard';
import HeaderWithBackButton from './HeaderWithBackButton';
import ScreenWrapper from './ScreenWrapper';
import SelectionList from './SelectionList';
Expand Down Expand Up @@ -85,6 +87,7 @@ function ApproverSelectionList({
const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE);
const shouldShowTextInput = shouldShowTextInputProp ?? allApprovers?.length >= CONST.STANDARD_LIST_ITEM_LIMIT;
const lazyIllustrations = useMemoizedLazyIllustrations(['TurtleInShell']);
const shouldFooterBeInsideList = useShouldFooterBeInsideList();

const handleSearchChange = useCallback(
(term: string) => {
Expand Down Expand Up @@ -169,11 +172,13 @@ function ApproverSelectionList({
onLinkPress={goBackFromInvalidPolicy}
addBottomSafeAreaPadding
>
<HeaderWithBackButton
title={headerTitle}
onBackButtonPress={onBackButtonPress}
/>
{subtitle}
<CollapsibleHeaderOnKeyboard>
<HeaderWithBackButton
title={headerTitle}
onBackButtonPress={onBackButtonPress}
/>
{subtitle}
</CollapsibleHeaderOnKeyboard>
<SelectionList
key={selectionListKey}
data={data}
Expand All @@ -188,6 +193,7 @@ function ApproverSelectionList({
shouldShowTextInput={shouldShowTextInput}
shouldShowLoadingPlaceholder={shouldShowLoadingPlaceholder}
footerContent={footerContent}
shouldFooterBeInsideList={shouldFooterBeInsideList}
addBottomSafeAreaPadding
shouldUpdateFocusedIndex={shouldUpdateFocusedIndex}
disableMaintainingScrollPosition
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type {SharedValue} from 'react-native-reanimated';

import {createContext, useContext} from 'react';

type CollapsibleHeaderOnKeyboardGroupContextValue = {
/** True while every member of the group has to be collapsed. */
shouldCollapse: SharedValue<boolean>;

/** Reports a member's natural (expanded) height, so the group can decide from the combined total of its members. */
setMemberNaturalHeight: (memberID: string, height: number) => void;

/** Drops a member's contribution to the total when it unmounts. */
unregisterMember: (memberID: string) => void;
};

const CollapsibleHeaderOnKeyboardGroupContext = createContext<CollapsibleHeaderOnKeyboardGroupContextValue | undefined>(undefined);

function useCollapsibleHeaderOnKeyboardGroup() {
return useContext(CollapsibleHeaderOnKeyboardGroupContext);
}

export default CollapsibleHeaderOnKeyboardGroupContext;
export {useCollapsibleHeaderOnKeyboardGroup};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import Reanimated from 'react-native-reanimated';

import type {CollapsibleHeader} from './useCollapsibleHeader';

type CollapsibleHeaderViewProps = {
children: React.ReactNode;

/** The state returned by `useCollapsibleHeader`. */
collapsibleHeader: CollapsibleHeader;
};

function CollapsibleHeaderView({children, collapsibleHeader}: CollapsibleHeaderViewProps) {
return (
<Reanimated.View style={collapsibleHeader.outerStyle}>
<Reanimated.View
onLayout={collapsibleHeader.onLayout}
style={collapsibleHeader.innerStyle}
>
{children}
</Reanimated.View>
</Reanimated.View>
);
}

export default CollapsibleHeaderView;
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import CollapsibleHeaderOnKeyboardGroupContext from '@components/CollapsibleHeaderOnKeyboard/CollapsibleHeaderOnKeyboardGroupContext';
import {getAvailableHeightForCollapsibleContent, getKeyboardCollapseState} from '@components/CollapsibleHeaderOnKeyboard/constants';
import type {CollapsibleHeaderOnKeyboardGroupProps} from '@components/CollapsibleHeaderOnKeyboard/types';
import useCollapsibleScreenState from '@components/CollapsibleHeaderOnKeyboard/useCollapsibleScreenState';
import useKeyboardCollapseMetrics from '@components/CollapsibleHeaderOnKeyboard/useKeyboardCollapseMetrics';

import React, {useEffect, useRef} from 'react';
import {useAnimatedReaction, useSharedValue} from 'react-native-reanimated';

/**
* Makes a single collapse decision for several `CollapsibleHeaderOnKeyboardGroupMember` instances
* that cannot share one wrapper because their JSX lives in different subtrees
*/
function CollapsibleHeaderOnKeyboardGroup({children, collapsibleHeaderOffset = 0}: CollapsibleHeaderOnKeyboardGroupProps) {
const shouldCollapse = useSharedValue(false);
const memberNaturalHeightsRef = useRef<Record<string, number>>({});
const totalNaturalHeight = useSharedValue(0);

const {isFocused, isInLandscapeMode, isFocusedSV, isInLandscapeModeSV} = useCollapsibleScreenState();
const {keyboardHeightSV, keyboardProgressSV, availableWindowHeightSV, collapsibleHeaderOffsetSV} = useKeyboardCollapseMetrics(collapsibleHeaderOffset);

// Collapsing only applies to a focused screen in landscape. Clear the flag on the way out so the members restore
// and a later reaction never acts on a decision that was made for a layout that no longer exists.
useEffect(() => {
if (isInLandscapeMode && isFocused) {
return;
}
shouldCollapse.set(false);
}, [isInLandscapeMode, isFocused, shouldCollapse]);

const updateTotalMembersNaturalHeight = () => {
totalNaturalHeight.set(Object.values(memberNaturalHeightsRef.current).reduce((total, height) => total + height, 0));
};

const setMemberNaturalHeight = (memberID: string, height: number) => {
if (memberNaturalHeightsRef.current[memberID] === height) {
return;
}
memberNaturalHeightsRef.current[memberID] = height;
updateTotalMembersNaturalHeight();
};

const unregisterMember = (memberID: string) => {
if (!(memberID in memberNaturalHeightsRef.current)) {
return;
}
delete memberNaturalHeightsRef.current[memberID];
updateTotalMembersNaturalHeight();
};

// Mirrors the single-instance reaction in `CollapsibleHeaderOnKeyboard`, except that it compares the combined
// natural height of every member instead of one header's height, and publishes a boolean the members follow.
useAnimatedReaction(
() => ({
keyboardHeight: keyboardHeightSV.get(),
keyboardProgress: keyboardProgressSV.get(),
availableWindowHeightValue: availableWindowHeightSV.get(),
totalNaturalHeightValue: totalNaturalHeight.get(),
}),
({keyboardHeight, keyboardProgress, availableWindowHeightValue, totalNaturalHeightValue}, previous) => {
// If the screen is not focused, bail out
if (!isFocusedSV.get() || !isInLandscapeModeSV.get()) {
return;
}

const {isKeyboardClosed, shouldReact} = getKeyboardCollapseState(keyboardProgress, previous?.keyboardProgress ?? 0, keyboardHeight);

// If the keyboard is closed, restore the members
if (isKeyboardClosed) {
shouldCollapse.set(false);
return;
}

if (!shouldReact) {
return;
}

// Nothing has been measured yet, so there is no total to compare against.
if (totalNaturalHeightValue <= 0) {
return;
}

// The members share what is left once the focused input and everything outside the group have their space.
const availableHeightForMembers = getAvailableHeightForCollapsibleContent(availableWindowHeightValue, keyboardHeight, collapsibleHeaderOffsetSV.get());

shouldCollapse.set(availableHeightForMembers < totalNaturalHeightValue);
},
);

return <CollapsibleHeaderOnKeyboardGroupContext.Provider value={{shouldCollapse, setMemberNaturalHeight, unregisterMember}}>{children}</CollapsibleHeaderOnKeyboardGroupContext.Provider>;
}

export default CollapsibleHeaderOnKeyboardGroup;
11 changes: 11 additions & 0 deletions src/components/CollapsibleHeaderOnKeyboard/Group/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type {CollapsibleHeaderOnKeyboardGroupProps} from '@components/CollapsibleHeaderOnKeyboard/types';

/**
* Web no-op that renders children as-is, matching `CollapsibleHeaderOnKeyboard`. The collapsing behaviour is only needed
* on native where the software keyboard reduces the visible viewport height.
*/
function CollapsibleHeaderOnKeyboardGroup({children}: CollapsibleHeaderOnKeyboardGroupProps) {
return children;
}

export default CollapsibleHeaderOnKeyboardGroup;
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {useCollapsibleHeaderOnKeyboardGroup} from '@components/CollapsibleHeaderOnKeyboard/CollapsibleHeaderOnKeyboardGroupContext';
import CollapsibleHeaderView from '@components/CollapsibleHeaderOnKeyboard/CollapsibleHeaderView';
import {MIN_HEADER_HEIGHT_ON_COLLAPSE} from '@components/CollapsibleHeaderOnKeyboard/constants';
import type {CollapsibleHeaderOnKeyboardGroupMemberProps} from '@components/CollapsibleHeaderOnKeyboard/types';
import useCollapsibleHeader, {collapseHeaderTo, restoreHeaderTo} from '@components/CollapsibleHeaderOnKeyboard/useCollapsibleHeader';

import React, {useEffect, useId, useRef} from 'react';
import {useAnimatedReaction, useSharedValue} from 'react-native-reanimated';

/**
* One element of a `CollapsibleHeaderOnKeyboardGroup`. Reports its measured height to the group and then follows the
* group's single decision, collapsing fully together with the group's other members.
*
* Use this instead of `CollapsibleHeaderOnKeyboard` whenever several collapsing elements stack on top of each other,
* so the space above the keyboard is weighed once against all of them rather than once per element.
*/
function CollapsibleHeaderOnKeyboardGroupMember({children}: CollapsibleHeaderOnKeyboardGroupMemberProps) {
const group = useCollapsibleHeaderOnKeyboardGroup();
const memberID = useId();
// `onLayout` only reports a height when it changes, so the last reported one is kept here to re-register with.
const reportedNaturalHeightRef = useRef(-1);
const collapsibleHeader = useCollapsibleHeader((height) => {
reportedNaturalHeightRef.current = height;
group?.setMemberNaturalHeight(memberID, height);
});
const {naturalHeight, animatedHeight, isFocusedSV, isInLandscapeModeSV} = collapsibleHeader;

const ungroupedShouldCollapse = useSharedValue(false);
const shouldCollapseSV = group?.shouldCollapse ?? ungroupedShouldCollapse;

// The cleanup drops this member's contribution to the group total. It runs on unmount, but also whenever the
// context value gets a new identity, so the height has to be put back on every run.
useEffect(() => {
if (!group) {
return;
}
if (reportedNaturalHeightRef.current !== -1) {
group.setMemberNaturalHeight(memberID, reportedNaturalHeightRef.current);
}
return () => group.unregisterMember(memberID);
}, [group, memberID]);

useAnimatedReaction(
() => ({shouldCollapse: shouldCollapseSV.get(), naturalHeightValue: naturalHeight.get()}),
({shouldCollapse, naturalHeightValue}) => {
if (!isFocusedSV.get() || !isInLandscapeModeSV.get() || naturalHeightValue === -1) {
return;
}

if (shouldCollapse) {
collapseHeaderTo(animatedHeight, MIN_HEADER_HEIGHT_ON_COLLAPSE);
return;
}
restoreHeaderTo(animatedHeight, naturalHeightValue);
},
);

return <CollapsibleHeaderView collapsibleHeader={collapsibleHeader}>{children}</CollapsibleHeaderView>;
}

export default CollapsibleHeaderOnKeyboardGroupMember;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type {CollapsibleHeaderOnKeyboardGroupMemberProps} from '@components/CollapsibleHeaderOnKeyboard/types';

/**
* Web no-op that renders children as-is, matching `CollapsibleHeaderOnKeyboard`. The collapsing behaviour is only needed
* on native where the software keyboard reduces the visible viewport height.
*/
function CollapsibleHeaderOnKeyboardGroupMember({children}: CollapsibleHeaderOnKeyboardGroupMemberProps) {
return children;
}

export default CollapsibleHeaderOnKeyboardGroupMember;
51 changes: 51 additions & 0 deletions src/components/CollapsibleHeaderOnKeyboard/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import variables from '@styles/variables';

const COLLAPSE_DURATION = 100;
const RESTORE_DURATION = 300;
// Assumed vertical space for the focused input field that is used to reserve space above the keyboard.
const VERTICAL_SPACE_FOR_FOCUSED_INPUT = variables.inputHeight + variables.inputPaddingBottom + variables.inputPaddingTop;
const KEYBOARD_OPENING_PROGRESS_THRESHOLDS = [0.5, 0.7, 0.8, 0.85, 0.9, 0.95, 0.99];
const MIN_HEADER_HEIGHT_ON_COLLAPSE = 8;

function isKeyboardOpeningAtGivenProgress(keyboardProgress: number, prevKeyboardProgress: number, requiredProgress: number[]): boolean {
'worklet';

return requiredProgress.some((progress) => keyboardProgress > progress && prevKeyboardProgress <= progress);
}

/**
* Tells a keyboard frame apart from the ones worth acting on, so that `CollapsibleHeaderOnKeyboard` and
* `CollapsibleHeaderOnKeyboardGroup` cannot drift apart on when they collapse.
*/
function getKeyboardCollapseState(keyboardProgress: number, prevKeyboardProgress: number, keyboardHeight: number): {isKeyboardClosed: boolean; shouldReact: boolean} {
'worklet';

if (keyboardProgress === 0 && keyboardHeight === 0) {
return {isKeyboardClosed: true, shouldReact: false};
}

// The keyboard is closing
if (prevKeyboardProgress > keyboardProgress) {
return {isKeyboardClosed: false, shouldReact: false};
}

const isKeyboardStartingOpening = prevKeyboardProgress === 0 && keyboardProgress > 0;
const isKeyboardOpeningAndReachingThreshold = isKeyboardOpeningAtGivenProgress(keyboardProgress, prevKeyboardProgress, KEYBOARD_OPENING_PROGRESS_THRESHOLDS);
const isKeyboardFullyOpen = keyboardProgress === 1;

return {isKeyboardClosed: false, shouldReact: isKeyboardStartingOpening || isKeyboardOpeningAndReachingThreshold || isKeyboardFullyOpen};
}

/**
* Vertical space the collapsing content can take once the keyboard, the focused input and everything accounted for by
* `collapsibleHeaderOffset` have taken theirs. Shared so the single-header and the group maths cannot diverge.
*/
function getAvailableHeightForCollapsibleContent(availableWindowHeight: number, keyboardHeight: number, collapsibleHeaderOffset: number): number {
'worklet';

// keyboardHeight is negative when open (e.g. -291), so keyboardTop = availableWindowHeight + keyboardHeight.
const keyboardTop = availableWindowHeight + keyboardHeight;
return keyboardTop - VERTICAL_SPACE_FOR_FOCUSED_INPUT - collapsibleHeaderOffset;
}

export {COLLAPSE_DURATION, RESTORE_DURATION, MIN_HEADER_HEIGHT_ON_COLLAPSE, getKeyboardCollapseState, getAvailableHeightForCollapsibleContent};
Loading
Loading