Skip to content

Commit

Permalink
Merge pull request #35870 from bernhardoj/fix/35649-highlight-moves-t…
Browse files Browse the repository at this point in the history
…o-top

Fix highlight moves to top when opening a workspace selector page
  • Loading branch information
amyevans authored Feb 6, 2024
2 parents 6a0e7ed + 424b239 commit 87a9dda
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/components/ValuePicker/ValueSelectorModal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash';
import PropTypes from 'prop-types';
import React, {useEffect, useState} from 'react';
import React, {useMemo} from 'react';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import Modal from '@components/Modal';
import ScreenWrapper from '@components/ScreenWrapper';
Expand Down Expand Up @@ -42,11 +42,9 @@ const defaultProps = {

function ValueSelectorModal({items, selectedItem, label, isVisible, onClose, onItemSelected, shouldShowTooltips}) {
const styles = useThemeStyles();
const [sectionsData, setSectionsData] = useState([]);

useEffect(() => {
const sections = useMemo(() => {
const itemsData = _.map(items, (item) => ({value: item.value, alternateText: item.description, keyForList: item.value, text: item.label, isSelected: item === selectedItem}));
setSectionsData(itemsData);
return [{data: itemsData}];
}, [items, selectedItem]);

return (
Expand All @@ -69,7 +67,7 @@ function ValueSelectorModal({items, selectedItem, label, isVisible, onClose, onI
onBackButtonPress={onClose}
/>
<SelectionList
sections={[{data: sectionsData}]}
sections={sections}
onSelectRow={onItemSelected}
initiallyFocusedOptionKey={selectedItem.value}
shouldStopPropagation
Expand Down

0 comments on commit 87a9dda

Please sign in to comment.