Skip to content

Commit c358b58

Browse files
author
Jake Stanger
committed
fix(taxonomy tree): options remain selected when switching in single mode
This is a hack fix since the tree is already built on top of React anti-patterns, which cause this in the first place. In the future a full refactor is really required to sort this out at its roots. By adding an unstable `key`, it forces the component to re-render on every render. Without this, React assumes nothing has changed and does not react to the `selectedKey` update. For large trees with everything expanded, this could cause performance issues but should be okay in most cases.
1 parent 36753f1 commit c358b58

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/controls/modernTaxonomyPicker/taxonomyTree/TaxonomyTree.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ export function TaxonomyTree(
659659
className={styles.taxonomyItemFocusZone}
660660
>
661661
<ChoiceGroup
662+
key={new Date().getTime()}
662663
options={options}
663664
selectedKey={
664665
props.selection && props.selection.getSelection()[0]?.id

0 commit comments

Comments
 (0)