From 0bb578b91fba11581d6f6d92c8743f15325a9cd2 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 15 Aug 2023 20:46:27 +0800 Subject: [PATCH 1/3] disable the list item if the section is disabled --- src/components/SelectionListRadio/BaseSelectionListRadio.js | 4 +++- src/components/SelectionListRadio/RadioListItem.js | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/SelectionListRadio/BaseSelectionListRadio.js b/src/components/SelectionListRadio/BaseSelectionListRadio.js index 4daacb184ea1..c9e4c14d6b81 100644 --- a/src/components/SelectionListRadio/BaseSelectionListRadio.js +++ b/src/components/SelectionListRadio/BaseSelectionListRadio.js @@ -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 ( ); diff --git a/src/components/SelectionListRadio/RadioListItem.js b/src/components/SelectionListRadio/RadioListItem.js index c5c4b3aeaf2c..9f1d7f6dd18c 100644 --- a/src/components/SelectionListRadio/RadioListItem.js +++ b/src/components/SelectionListRadio/RadioListItem.js @@ -16,6 +16,9 @@ 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, }; @@ -23,6 +26,7 @@ const propTypes = { const defaultProps = { item: {}, isFocused: false, + isDisabled: false, onSelectRow: () => {}, }; @@ -30,6 +34,7 @@ function RadioListItem(props) { return ( props.onSelectRow(props.item)} + disabled={props.isDisabled} accessibilityLabel={props.item.text} accessibilityRole="button" hoverDimmingValue={1} From 827792546fbaa0cc0685a7d5cfa409821f87b95d Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 15 Aug 2023 20:47:28 +0800 Subject: [PATCH 2/3] fix user current timezone does not updated dynamically --- src/pages/settings/Profile/TimezoneSelectPage.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/settings/Profile/TimezoneSelectPage.js b/src/pages/settings/Profile/TimezoneSelectPage.js index 8ca0320783d4..1bed325c435a 100644 --- a/src/pages/settings/Profile/TimezoneSelectPage.js +++ b/src/pages/settings/Profile/TimezoneSelectPage.js @@ -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); /** @@ -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')} /> ); From b7ae91216539bc89228b89dd692a1d947f5b23c2 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 18 Aug 2023 21:26:03 +0800 Subject: [PATCH 3/3] remove focus style --- src/components/SelectionListRadio/RadioListItem.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/SelectionListRadio/RadioListItem.js b/src/components/SelectionListRadio/RadioListItem.js index 9f1d7f6dd18c..615619f928f4 100644 --- a/src/components/SelectionListRadio/RadioListItem.js +++ b/src/components/SelectionListRadio/RadioListItem.js @@ -39,7 +39,6 @@ function RadioListItem(props) { accessibilityRole="button" hoverDimmingValue={1} hoverStyle={styles.hoveredComponentBG} - focusStyle={styles.hoveredComponentBG} >