From a4c949471bcebef0e4cb1495c93866f5e6b0d903 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 20 Feb 2024 15:19:10 +0800 Subject: [PATCH] disable tab only on start page --- src/pages/iou/request/IOURequestStartPage.js | 27 +++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/pages/iou/request/IOURequestStartPage.js b/src/pages/iou/request/IOURequestStartPage.js index 3d80ab89347d..cb6ff07c819d 100644 --- a/src/pages/iou/request/IOURequestStartPage.js +++ b/src/pages/iou/request/IOURequestStartPage.js @@ -1,3 +1,4 @@ +import {useFocusEffect} from '@react-navigation/native'; import lodashGet from 'lodash/get'; import PropTypes from 'prop-types'; import React, {useCallback, useEffect, useRef, useState} from 'react'; @@ -88,18 +89,20 @@ function IOURequestStartPage({ [reportID], ); - useEffect(() => { - const handler = (event) => { - if (event.code !== CONST.KEYBOARD_SHORTCUTS.TAB.shortcutKey) { - return; - } - event.preventDefault(); - event.stopPropagation(); - }; - KeyDownPressListener.addKeyDownPressListener(handler); - - return () => KeyDownPressListener.removeKeyDownPressListener(handler); - }, []); + useFocusEffect( + useCallback(() => { + const handler = (event) => { + if (event.code !== CONST.KEYBOARD_SHORTCUTS.TAB.shortcutKey) { + return; + } + event.preventDefault(); + event.stopPropagation(); + }; + KeyDownPressListener.addKeyDownPressListener(handler); + + return () => KeyDownPressListener.removeKeyDownPressListener(handler); + }, []), + ); // Clear out the temporary money request if the reportID in the URL has changed from the transaction's reportID useEffect(() => {