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

Disable timezone list if automatic timezone is turned on #24577

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
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,14 @@ function BaseSelectionListRadio(props) {
};

const renderItem = ({item, index, section}) => {
const isFocused = focusedIndex === index + lodashGet(section, 'indexOffset', 0);
const isDisabled = section.isDisabled;
const isFocused = !isDisabled && focusedIndex === index + lodashGet(section, 'indexOffset', 0);

return (
<RadioListItem
item={item}
isFocused={isFocused}
isDisabled={isDisabled}
onSelectRow={props.onSelectRow}
/>
);
Expand Down
6 changes: 5 additions & 1 deletion src/components/SelectionListRadio/RadioListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,29 @@ const propTypes = {
/** Whether this item is focused (for arrow key controls) */
isFocused: PropTypes.bool,

/** Whether this item is disabled */
isDisabled: PropTypes.bool,

/** Callback to fire when the item is pressed */
onSelectRow: PropTypes.func,
};

const defaultProps = {
item: {},
isFocused: false,
isDisabled: false,
onSelectRow: () => {},
};

function RadioListItem(props) {
return (
<PressableWithFeedback
onPress={() => props.onSelectRow(props.item)}
disabled={props.isDisabled}
accessibilityLabel={props.item.text}
accessibilityRole="button"
hoverDimmingValue={1}
hoverStyle={styles.hoveredComponentBG}
focusStyle={styles.hoveredComponentBG}
>
<View style={[styles.flex1, styles.justifyContentBetween, styles.sidebarLinkInner, styles.optionRow, props.isFocused && styles.sidebarLinkActive]}>
<View style={[styles.flex1, styles.alignItemsStart]}>
Expand Down
10 changes: 5 additions & 5 deletions src/pages/settings/Profile/TimezoneSelectPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ const getUserTimezone = (currentUserPersonalDetails) => lodashGet(currentUserPer

function TimezoneSelectPage(props) {
const {translate} = useLocalize();
const timezone = useRef(getUserTimezone(props.currentUserPersonalDetails));
const timezone = getUserTimezone(props.currentUserPersonalDetails);
const allTimezones = useRef(
_.chain(moment.tz.names())
.filter((tz) => !tz.startsWith('Etc/GMT'))
.map((text) => ({
text,
keyForList: getKey(text),
isSelected: text === timezone.current.selected,
isSelected: text === timezone.selected,
}))
.value(),
);
const [timezoneInputText, setTimezoneInputText] = useState(timezone.current.selected);
const [timezoneInputText, setTimezoneInputText] = useState(timezone.selected);
const [timezoneOptions, setTimezoneOptions] = useState(allTimezones.current);

/**
Expand Down Expand Up @@ -76,8 +76,8 @@ function TimezoneSelectPage(props) {
textInputValue={timezoneInputText}
onChangeText={filterShownTimezones}
onSelectRow={saveSelectedTimezone}
sections={[{data: timezoneOptions, indexOffset: 0, isDisabled: timezone.current.automatic}]}
initiallyFocusedOptionKey={_.get(_.filter(timezoneOptions, (tz) => tz.text === timezone.current.selected)[0], 'keyForList')}
sections={[{data: timezoneOptions, indexOffset: 0, isDisabled: timezone.automatic}]}
initiallyFocusedOptionKey={_.get(_.filter(timezoneOptions, (tz) => tz.text === timezone.selected)[0], 'keyForList')}
/>
</ScreenWrapper>
);
Expand Down