Skip to content

Commit d3bf94b

Browse files
authored
Merge pull request Expensify#76515 from software-mansion-labs/fix/saml-metadata-text-input
fix: Invalid character error in SAML Identity Provider Metadata input + initial cursor position
2 parents ba34b92 + 3f2740b commit d3bf94b

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

src/components/TextPicker/TextSelectorModal.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import Modal from '@components/Modal';
1010
import ScreenWrapper from '@components/ScreenWrapper';
1111
import Text from '@components/Text';
1212
import TextInput from '@components/TextInput';
13-
import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types';
1413
import useLocalize from '@hooks/useLocalize';
1514
import useResponsiveLayout from '@hooks/useResponsiveLayout';
1615
import useThemeStyles from '@hooks/useThemeStyles';
16+
import {moveSelectionToEnd, scrollToBottom} from '@libs/InputUtils';
1717
import {getFieldRequiredErrors} from '@libs/ValidationUtils';
1818
import CONST from '@src/CONST';
1919
import ONYXKEYS from '@src/ONYXKEYS';
@@ -32,6 +32,8 @@ function TextSelectorModal({
3232
required = false,
3333
customValidate,
3434
enabledWhenOffline = true,
35+
allowHTML,
36+
autoGrowHeight,
3537
...rest
3638
}: TextSelectorModalProps) {
3739
const {translate} = useLocalize();
@@ -40,11 +42,10 @@ function TextSelectorModal({
4042

4143
const [currentValue, setValue] = useState(value);
4244

43-
const inputRef = useRef<BaseTextInputRef | null>(null);
45+
const inputRef = useRef<TextInputType | null>(null);
4446
const inputValueRef = useRef(value);
4547
const focusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
46-
47-
const inputCallbackRef = (ref: BaseTextInputRef | null) => {
48+
const inputCallbackRef = (ref: TextInputType | null) => {
4849
inputRef.current = ref;
4950
};
5051

@@ -97,7 +98,11 @@ function TextSelectorModal({
9798
focusTimeoutRef.current = setTimeout(() => {
9899
if (inputRef.current && isVisible) {
99100
inputRef.current.focus();
100-
(inputRef.current as TextInputType).setSelection?.(inputValueRef.current?.length ?? 0, inputValueRef.current?.length ?? 0);
101+
inputRef.current.setSelection?.(inputValueRef.current?.length ?? 0, inputValueRef.current?.length ?? 0);
102+
if (autoGrowHeight) {
103+
scrollToBottom(inputRef.current);
104+
moveSelectionToEnd(inputRef.current);
105+
}
101106
}
102107
return () => {
103108
if (!focusTimeoutRef.current || !isVisible) {
@@ -106,7 +111,7 @@ function TextSelectorModal({
106111
clearTimeout(focusTimeoutRef.current);
107112
};
108113
}, CONST.ANIMATED_TRANSITION);
109-
}, [isVisible]),
114+
}, [isVisible, autoGrowHeight]),
110115
);
111116

112117
const handleSubmit = useCallback(
@@ -155,6 +160,7 @@ function TextSelectorModal({
155160
shouldHideFixErrorsAlert
156161
addBottomSafeAreaPadding
157162
enterKeyEventListenerPriority={0}
163+
allowHTML={allowHTML}
158164
>
159165
{!!subtitle && (
160166
<View style={styles.pb4}>
@@ -169,6 +175,7 @@ function TextSelectorModal({
169175
// eslint-disable-next-line react/jsx-props-no-spreading
170176
{...rest}
171177
inputID={rest.inputID}
178+
autoGrowHeight={autoGrowHeight}
172179
/>
173180
</FormProvider>
174181
</ScreenWrapper>

src/components/TextPicker/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ type TextSelectorModalProps = {
3535

3636
/** Whether the form should be actionable when offline */
3737
enabledWhenOffline?: boolean;
38+
39+
/** Whether HTML is allowed in form inputs */
40+
allowHTML?: boolean;
3841
} & Pick<MenuItemBaseProps, 'subtitle' | 'description'> &
3942
Omit<TextProps, 'ref'>;
4043

@@ -75,6 +78,9 @@ type TextPickerProps = {
7578
/** Whether the form should be actionable when offline */
7679
enabledWhenOffline?: boolean;
7780

81+
/** Whether HTML is allowed in form inputs */
82+
allowHTML?: boolean;
83+
7884
/** Reference to the outer element */
7985
ref?: ForwardedRef<View>;
8086
} & Pick<MenuItemBaseProps, 'rightLabel' | 'subtitle' | 'description' | 'interactive' | 'wrapperStyle' | 'numberOfLinesTitle' | 'titleStyle' | 'descriptionTextStyle'> &

src/pages/domain/Saml/SamlConfigurationDetailsSectionContent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ function SamlConfigurationDetailsSectionContent({accountID, domainName, shouldSh
8080
maxLength={Infinity}
8181
enabledWhenOffline={false}
8282
required
83+
allowHTML
8384
/>
8485

8586
<MenuItemWithTopDescription

0 commit comments

Comments
 (0)