Skip to content

Commit

Permalink
feat: dynamic value change for ui.tabs - args fix
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-mihok committed Aug 21, 2023
1 parent 3dd0a8c commit 372304c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ui/src/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const
onLinkClick = (item?: Fluent.PivotItem) => {
const name = item?.props.itemKey
if (!name) return
m.value = name
setSelected(name)
if (name.startsWith('#')) {
window.location.hash = name.substring(1)
Expand All @@ -84,7 +85,12 @@ export const
tabs = m.items?.map(t => <Fluent.PivotItem key={t.name} itemIcon={t.icon} itemKey={t.name} headerText={t.label} />),
[selected, setSelected] = React.useState(m.value)

React.useEffect(() => setSelected(m.value), [m.value])
React.useEffect(() => {
setSelected(m.value)
if (!m.value) wave.args[m.name] = null
else if (m.value.startsWith('#')) window.location.hash = m.value.substring(1)
else if (m.name && m.value !== wave.args[m.name]) wave.args[m.name] = m.value
}, [m.name, m.value])

return (
<div className={css.pivot}>
Expand Down

0 comments on commit 372304c

Please sign in to comment.