Skip to content

Commit

Permalink
fix: no navigation object in state picker storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
tienifr committed Mar 20, 2024
1 parent ddf9e7a commit 6232623
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
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

0 comments on commit 6232623

Please sign in to comment.