-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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: Workflows - Offline indicator is present below the last option instead of page bottom. #42019
Changes from 4 commits
422ba55
6ddaad4
47abac3
ce82f83
5ebd6d9
9350a31
2cbeb45
df2b6b7
0be8338
b565f2c
8106011
f5e5f49
9e8e01b
0f58c9a
cf0be8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,12 +1,12 @@ | ||||||||
import type {StackScreenProps} from '@react-navigation/stack'; | ||||||||
import React, {useState} from 'react'; | ||||||||
import {FlatList} from 'react-native-gesture-handler'; | ||||||||
import type {ValueOf} from 'type-fest'; | ||||||||
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; | ||||||||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||||||||
import MenuItem from '@components/MenuItem'; | ||||||||
import OfflineWithFeedback from '@components/OfflineWithFeedback'; | ||||||||
import ScreenWrapper from '@components/ScreenWrapper'; | ||||||||
import SelectionList from '@components/SelectionList'; | ||||||||
import RadioListItem from '@components/SelectionList/RadioListItem'; | ||||||||
import useLocalize from '@hooks/useLocalize'; | ||||||||
import useThemeStyles from '@hooks/useThemeStyles'; | ||||||||
|
@@ -33,6 +33,7 @@ type WorkspaceAutoReportingFrequencyPageItem = { | |||||||
text: string; | ||||||||
keyForList: string; | ||||||||
isSelected: boolean; | ||||||||
footerComponent?: React.ReactNode | null; | ||||||||
}; | ||||||||
|
||||||||
type AutoReportingFrequencyDisplayNames = Record<AutoReportingFrequencyKey, string>; | ||||||||
|
@@ -51,16 +52,6 @@ function WorkspaceAutoReportingFrequencyPage({policy, route}: WorkspaceAutoRepor | |||||||
const styles = useThemeStyles(); | ||||||||
const [isMonthlyFrequency, setIsMonthlyFrequency] = useState(policy?.autoReportingFrequency === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY); | ||||||||
|
||||||||
const autoReportingFrequencyItems: WorkspaceAutoReportingFrequencyPageItem[] = Object.keys(getAutoReportingFrequencyDisplayNames(preferredLocale)).map((frequencyKey) => { | ||||||||
const isSelected = policy?.autoReportingFrequency === frequencyKey; | ||||||||
|
||||||||
return { | ||||||||
text: getAutoReportingFrequencyDisplayNames(preferredLocale)[frequencyKey as AutoReportingFrequencyKey] || '', | ||||||||
keyForList: frequencyKey, | ||||||||
isSelected, | ||||||||
}; | ||||||||
}); | ||||||||
|
||||||||
const onSelectAutoReportingFrequency = (item: WorkspaceAutoReportingFrequencyPageItem) => { | ||||||||
Policy.setWorkspaceAutoReportingFrequency(policy?.id ?? '', item.keyForList as AutoReportingFrequencyKey); | ||||||||
|
||||||||
|
@@ -106,16 +97,16 @@ function WorkspaceAutoReportingFrequencyPage({policy, route}: WorkspaceAutoRepor | |||||||
</OfflineWithFeedback> | ||||||||
); | ||||||||
|
||||||||
const renderItem = ({item}: {item: WorkspaceAutoReportingFrequencyPageItem}) => ( | ||||||||
<> | ||||||||
<RadioListItem | ||||||||
item={item} | ||||||||
onSelectRow={() => onSelectAutoReportingFrequency(item)} | ||||||||
showTooltip={false} | ||||||||
/> | ||||||||
{isMonthlyFrequency && item.keyForList === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY ? monthlyFrequencyDetails() : null} | ||||||||
</> | ||||||||
); | ||||||||
const autoReportingFrequencyItems: WorkspaceAutoReportingFrequencyPageItem[] = Object.keys(getAutoReportingFrequencyDisplayNames(preferredLocale)).map((frequencyKey) => { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can put it into a memo to memorize this output There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is necessary, but if we decide to use memo, we would also need to wrap There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uhm, let's keep it as it's |
||||||||
const isSelected = policy?.autoReportingFrequency === frequencyKey; | ||||||||
|
||||||||
return { | ||||||||
text: getAutoReportingFrequencyDisplayNames(preferredLocale)[frequencyKey as AutoReportingFrequencyKey] || '', | ||||||||
keyForList: frequencyKey, | ||||||||
isSelected, | ||||||||
footerComponent: isMonthlyFrequency && frequencyKey === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY ? monthlyFrequencyDetails() : null, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
If it's a component we should name it capitalize There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hoangzinh, we use camelCase for components as well, and instead of component we use content, so I replaced There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't show footerContent when I select "Monthly" option. Could you take a look? Screen.Recording.2024-05-21.at.22.23.44.movThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hoangzinh, maybe you don't have access, I just removed that check for testing.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, sorry there was a typo, I forgot to update |
||||||||
}; | ||||||||
}); | ||||||||
|
||||||||
return ( | ||||||||
<AccessOrNotFoundWrapper | ||||||||
|
@@ -140,11 +131,14 @@ function WorkspaceAutoReportingFrequencyPage({policy, route}: WorkspaceAutoRepor | |||||||
pendingAction={policy?.pendingFields?.autoReportingFrequency} | ||||||||
errors={ErrorUtils.getLatestErrorField(policy ?? {}, CONST.POLICY.COLLECTION_KEYS.AUTOREPORTING_FREQUENCY)} | ||||||||
onClose={() => Policy.clearPolicyErrorField(policy?.id ?? '', CONST.POLICY.COLLECTION_KEYS.AUTOREPORTING_FREQUENCY)} | ||||||||
style={styles.flex1} | ||||||||
contentContainerStyle={styles.flex1} | ||||||||
> | ||||||||
<FlatList | ||||||||
data={autoReportingFrequencyItems} | ||||||||
renderItem={renderItem} | ||||||||
keyExtractor={(item: WorkspaceAutoReportingFrequencyPageItem) => item.text} | ||||||||
<SelectionList | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coming from this #47574 |
||||||||
ListItem={RadioListItem} | ||||||||
sections={[{data: autoReportingFrequencyItems}]} | ||||||||
onSelectRow={onSelectAutoReportingFrequency} | ||||||||
initiallyFocusedOptionKey={policy?.autoReportingFrequency} | ||||||||
/> | ||||||||
</OfflineWithFeedback> | ||||||||
</FullPageNotFoundView> | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this change @Krishna2323?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a focus issue with the newly selected option. Although I don't completely remember the exact bug. I removed this code as I can't reproduce any bug like that.