-
Notifications
You must be signed in to change notification settings - Fork 4k
Fix Save button unreachable behind keyboard on EditPromptPage in landscape #100643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+32
−19
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
00c7d80
Fix Save button unreachable behind keyboard on EditPromptPage in land…
NicolasBonet f16a419
Clip shrunk prompt input so overflow scrolls instead of bleeding into…
NicolasBonet 0f79840
Wrap the prompt input and disclaimer to mirror AddAgentPage's layout
NicolasBonet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||||
| import CollapsibleHeaderOnKeyboard from '@components/CollapsibleHeaderOnKeyboard'; | ||||||||
| import FormProvider from '@components/Form/FormProvider'; | ||||||||
| import InputWrapper from '@components/Form/InputWrapper'; | ||||||||
| import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; | ||||||||
| import type {FormInputErrors, FormOnyxValues, FormRef} from '@components/Form/types'; | ||||||||
| import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||||||||
| import ScreenWrapper from '@components/ScreenWrapper'; | ||||||||
| import Text from '@components/Text'; | ||||||||
|
|
@@ -21,14 +21,15 @@ import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavig | |||||||
| import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; | ||||||||
|
|
||||||||
| import {PROMPT_MAX_HEIGHT_ON_KEYBOARD_OPEN_LANDSCAPE_MODE} from '@pages/settings/Agents/const'; | ||||||||
| import scrollToMultilineInput from '@pages/settings/Agents/scrollToMultilineInput'; | ||||||||
|
|
||||||||
| import CONST from '@src/CONST'; | ||||||||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||||||||
| import type SCREENS from '@src/SCREENS'; | ||||||||
| import INPUT_IDS from '@src/types/form/EditAgentPromptForm'; | ||||||||
|
|
||||||||
| import {Str} from 'expensify-common'; | ||||||||
| import React from 'react'; | ||||||||
| import React, {useRef} from 'react'; | ||||||||
| import {Platform, View} from 'react-native'; | ||||||||
|
|
||||||||
| type EditPromptPageProps = PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.AGENTS.EDIT_PROMPT>; | ||||||||
|
|
@@ -42,6 +43,9 @@ function EditPromptPage({route}: EditPromptPageProps) { | |||||||
| const shouldShrinkPromptInput = isInLandscapeMode && isKeyboardActive; | ||||||||
| const accountID = route.params.accountID; | ||||||||
| const [agentPrompt] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_AGENT_PROMPT}${accountID}`); | ||||||||
| const formRef = useRef<FormRef>(null); | ||||||||
| const promptTopOffsetRef = useRef(0); | ||||||||
| const handleInputFocus = () => scrollToMultilineInput(formRef, isInLandscapeMode, promptTopOffsetRef.current); | ||||||||
|
|
||||||||
| const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.EDIT_AGENT_PROMPT_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.EDIT_AGENT_PROMPT_FORM> => { | ||||||||
| const errors: FormInputErrors<typeof ONYXKEYS.FORMS.EDIT_AGENT_PROMPT_FORM> = {}; | ||||||||
|
|
@@ -88,36 +92,45 @@ function EditPromptPage({route}: EditPromptPageProps) { | |||||||
| /> | ||||||||
| </CollapsibleHeaderOnKeyboard> | ||||||||
| <FormProvider | ||||||||
| ref={formRef} | ||||||||
| formID={ONYXKEYS.FORMS.EDIT_AGENT_PROMPT_FORM} | ||||||||
| validate={validate} | ||||||||
| onSubmit={handleSubmit} | ||||||||
| submitButtonText={translate('common.save')} | ||||||||
| style={[styles.flex1, styles.ph5]} | ||||||||
| shouldUseScrollView={false} | ||||||||
| shouldUseScrollView={isInLandscapeMode} | ||||||||
| submitFlexEnabled={false} | ||||||||
| enabledWhenOffline | ||||||||
| shouldHideFixErrorsAlert | ||||||||
| shouldValidateOnChange | ||||||||
| shouldValidateOnBlur | ||||||||
| keyboardSubmitBehavior={CONST.KEYBOARD_SUBMIT_BEHAVIOR.SUBMIT_ONLY} | ||||||||
| > | ||||||||
| <View style={shouldShrinkPromptInput ? StyleUtils.getHeight(PROMPT_MAX_HEIGHT_ON_KEYBOARD_OPEN_LANDSCAPE_MODE) : [styles.flex1]}> | ||||||||
| <InputWrapper | ||||||||
| InputComponent={TextInput} | ||||||||
| inputID={INPUT_IDS.PROMPT} | ||||||||
| label={translate('editAgentPage.instructions')} | ||||||||
| accessibilityLabel={translate('editAgentPage.instructions')} | ||||||||
| role={CONST.ROLE.PRESENTATION} | ||||||||
| type="markdown" | ||||||||
| excludedMarkdownStyles={['mentionReport']} | ||||||||
| defaultValue={Str.htmlDecode(agentPrompt?.prompt ?? '')} | ||||||||
| multiline | ||||||||
| containerStyles={[styles.h100]} | ||||||||
| touchableInputWrapperStyle={[styles.flex1]} | ||||||||
| inputStyle={[styles.flex1, styles.textAlignVerticalTop]} | ||||||||
| /> | ||||||||
| <View style={[styles.flex1, styles.flexColumn, styles.gap5]}> | ||||||||
| <View | ||||||||
| style={shouldShrinkPromptInput ? StyleUtils.getHeight(PROMPT_MAX_HEIGHT_ON_KEYBOARD_OPEN_LANDSCAPE_MODE) : [styles.flex1]} | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be:
Suggested change
here or else it's broken with open keyboard when the prompt is longer: Screen.Recording.2026-09-09.at.09.19.39.mov
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed here |
||||||||
| onLayout={(event) => { | ||||||||
| promptTopOffsetRef.current = event.nativeEvent.layout.y; | ||||||||
| }} | ||||||||
| > | ||||||||
| <InputWrapper | ||||||||
| InputComponent={TextInput} | ||||||||
| inputID={INPUT_IDS.PROMPT} | ||||||||
| label={translate('editAgentPage.instructions')} | ||||||||
| accessibilityLabel={translate('editAgentPage.instructions')} | ||||||||
| role={CONST.ROLE.PRESENTATION} | ||||||||
| type="markdown" | ||||||||
| excludedMarkdownStyles={['mentionReport']} | ||||||||
| defaultValue={Str.htmlDecode(agentPrompt?.prompt ?? '')} | ||||||||
| multiline | ||||||||
| containerStyles={[styles.h100]} | ||||||||
| touchableInputWrapperStyle={[styles.flex1]} | ||||||||
| inputStyle={[styles.flex1, styles.textAlignVerticalTop]} | ||||||||
| onFocus={handleInputFocus} | ||||||||
| /> | ||||||||
| </View> | ||||||||
| <Text style={[styles.textMicroSupporting, styles.textAlignCenter]}>{translate('workspace.rules.agentRules.disclaimer')}</Text> | ||||||||
| </View> | ||||||||
| <Text style={[styles.textMicroSupporting, styles.textAlignCenter, styles.mt2]}>{translate('workspace.rules.agentRules.disclaimer')}</Text> | ||||||||
| </FormProvider> | ||||||||
| </ScreenWrapper> | ||||||||
| ); | ||||||||
|
|
||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ CONSISTENCY-12 (docs)
The declared function
handleInputFocusis named for the event it is wired to (the input'sonFocus) rather than the action it performs (scrolling the prompt input into view). Per STYLE.md, a callback's definition should be named for its behavior; theon*/handle*naming belongs on the JSX prop, not the function definition. A behavior-based name keeps the handler searchable by intent and reusable across triggers.Rename the declaration to describe what it does, e.g.:
Reviewed at: 0f79840 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.