Skip to content
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

Fix - Saved search - Unable to delete saved search using Enter key #49864

Merged
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
19 changes: 16 additions & 3 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,24 @@ type ButtonProps = Partial<ChildrenProps> & {

/** Whether button's content should be centered */
isContentCentered?: boolean;

/** Whether the Enter keyboard listening is active whether or not the screen that contains the button is focused */
isPressOnEnterActive?: boolean;
};

type KeyboardShortcutComponentProps = Pick<ButtonProps, 'isDisabled' | 'isLoading' | 'onPress' | 'pressOnEnter' | 'allowBubble' | 'enterKeyEventListenerPriority'>;
type KeyboardShortcutComponentProps = Pick<ButtonProps, 'isDisabled' | 'isLoading' | 'onPress' | 'pressOnEnter' | 'allowBubble' | 'enterKeyEventListenerPriority' | 'isPressOnEnterActive'>;

const accessibilityRoles: string[] = Object.values(CONST.ROLE);

function KeyboardShortcutComponent({isDisabled = false, isLoading = false, onPress = () => {}, pressOnEnter, allowBubble, enterKeyEventListenerPriority}: KeyboardShortcutComponentProps) {
function KeyboardShortcutComponent({
isDisabled = false,
isLoading = false,
onPress = () => {},
pressOnEnter,
allowBubble,
enterKeyEventListenerPriority,
isPressOnEnterActive = false,
}: KeyboardShortcutComponentProps) {
const isFocused = useIsFocused();
const activeElementRole = useActiveElementRole();

Expand All @@ -163,7 +174,7 @@ function KeyboardShortcutComponent({isDisabled = false, isLoading = false, onPre

const config = useMemo(
() => ({
isActive: pressOnEnter && !shouldDisableEnterShortcut && isFocused,
isActive: pressOnEnter && !shouldDisableEnterShortcut && (isFocused || isPressOnEnterActive),
shouldBubble: allowBubble,
priority: enterKeyEventListenerPriority,
shouldPreventDefault: false,
Expand Down Expand Up @@ -230,6 +241,7 @@ function Button(
isSplitButton = false,
link = false,
isContentCentered = false,
isPressOnEnterActive,
...rest
}: ButtonProps,
ref: ForwardedRef<View>,
Expand Down Expand Up @@ -329,6 +341,7 @@ function Button(
onPress={onPress}
pressOnEnter={pressOnEnter}
enterKeyEventListenerPriority={enterKeyEventListenerPriority}
isPressOnEnterActive={isPressOnEnterActive}
/>
)}
<PressableWithFeedback
Expand Down
6 changes: 6 additions & 0 deletions src/components/ConfirmContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ type ConfirmContentProps = {

/** Image to display with content */
image?: IconAsset;

/** Whether the modal is visibile */
isVisible: boolean;
};

function ConfirmContent({
Expand Down Expand Up @@ -123,6 +126,7 @@ function ConfirmContent({
image,
titleContainerStyles,
shouldReverseStackedButtons = false,
isVisible,
}: ConfirmContentProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand Down Expand Up @@ -200,6 +204,7 @@ function ConfirmContent({
style={shouldReverseStackedButtons ? styles.mt3 : styles.mt4}
onPress={onConfirm}
pressOnEnter
isPressOnEnterActive={isVisible}
large
text={confirmText || translate('common.yes')}
isDisabled={isOffline && shouldDisableConfirmButtonWhenOffline}
Expand Down Expand Up @@ -228,6 +233,7 @@ function ConfirmContent({
style={[styles.flex1]}
onPress={onConfirm}
pressOnEnter
isPressOnEnterActive={isVisible}
text={confirmText || translate('common.yes')}
isDisabled={isOffline && shouldDisableConfirmButtonWhenOffline}
/>
Expand Down
1 change: 1 addition & 0 deletions src/components/ConfirmModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ function ConfirmModal({
prompt={prompt}
success={success}
danger={danger}
isVisible={isVisible}
shouldDisableConfirmButtonWhenOffline={shouldDisableConfirmButtonWhenOffline}
shouldShowCancelButton={shouldShowCancelButton}
shouldCenterContent={shouldCenterContent}
Expand Down
Loading