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: No navigation object in state picker story #38659

Merged
merged 1 commit into from
Mar 23, 2024
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
5 changes: 1 addition & 4 deletions src/components/HeaderWithBackButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useThrottledButtonState from '@hooks/useThrottledButtonState';
import useWaitForNavigation from '@hooks/useWaitForNavigation';
import getButtonState from '@libs/getButtonState';
import Navigation from '@libs/Navigation/Navigation';
import variables from '@styles/variables';
Expand Down Expand Up @@ -58,7 +57,6 @@ function HeaderWithBackButton({
children = null,
shouldOverlayDots = false,
shouldOverlay = false,
singleExecution = (func) => func,
shouldNavigateToTopMostReport = false,
style,
}: HeaderWithBackButtonProps) {
Expand All @@ -68,7 +66,6 @@ function HeaderWithBackButton({
const [isDownloadButtonActive, temporarilyDisableDownloadButton] = useThrottledButtonState();
const {translate} = useLocalize();
const {isKeyboardShown} = useKeyboardState();
const waitForNavigate = useWaitForNavigation();

// If the icon is present, the header bar should be taller and use different font.
const isCentralPaneSettings = !!icon;
Expand Down Expand Up @@ -175,7 +172,7 @@ function HeaderWithBackButton({
<Tooltip text={translate('getAssistancePage.questionMarkButtonTooltip')}>
<PressableWithoutFeedback
disabled={shouldDisableGetAssistanceButton}
onPress={singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.GET_ASSISTANCE.getRoute(guidesCallTaskID, Navigation.getActiveRoute()))))}
onPress={() => Navigation.navigate(ROUTES.GET_ASSISTANCE.getRoute(guidesCallTaskID, Navigation.getActiveRoute()))}
style={[styles.touchableButtonImage]}
role="button"
accessibilityLabel={translate('getAssistancePage.questionMarkButtonTooltip')}
Expand Down
3 changes: 2 additions & 1 deletion src/components/ScreenWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import KeyboardAvoidingView from './KeyboardAvoidingView';
import OfflineIndicator from './OfflineIndicator';
import SafeAreaConsumer from './SafeAreaConsumer';
import TestToolsModal from './TestToolsModal';
import withNavigationFallback from './withNavigationFallback';

type ChildrenProps = {
insets: EdgeInsets;
Expand Down Expand Up @@ -279,4 +280,4 @@ function ScreenWrapper(

ScreenWrapper.displayName = 'ScreenWrapper';

export default forwardRef(ScreenWrapper);
export default withNavigationFallback(forwardRef(ScreenWrapper));
11 changes: 4 additions & 7 deletions src/stories/HeaderWithBackButton.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@ import type {ComponentMeta, ComponentStory} from '@storybook/react';
import React from 'react';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import type HeaderWithBackButtonProps from '@components/HeaderWithBackButton/types';
import withNavigationFallback from '@components/withNavigationFallback';

const HeaderWithBackButtonWithNavigation = withNavigationFallback(HeaderWithBackButton);

type HeaderWithBackButtonStory = ComponentStory<typeof HeaderWithBackButtonWithNavigation>;
type HeaderWithBackButtonStory = ComponentStory<typeof HeaderWithBackButton>;

/**
* We use the Component Story Format for writing stories. Follow the docs here:
*
* https://storybook.js.org/docs/react/writing-stories/introduction#component-story-format
*/
const story: ComponentMeta<typeof HeaderWithBackButtonWithNavigation> = {
const story: ComponentMeta<typeof HeaderWithBackButton> = {
title: 'Components/HeaderWithBackButton',
component: HeaderWithBackButtonWithNavigation,
component: HeaderWithBackButton,
};

function Template(props: HeaderWithBackButtonProps) {
// eslint-disable-next-line react/jsx-props-no-spreading
return <HeaderWithBackButtonWithNavigation {...props} />;
return <HeaderWithBackButton {...props} />;
}

// Arguments can be passed to the component by binding
Expand Down
Loading