Skip to content

Commit

Permalink
fix(choicefield): enable popover only on editing
Browse files Browse the repository at this point in the history
  • Loading branch information
schettn authored Sep 8, 2021
1 parent 7dc6c5c commit 4ee9231
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/my-gatsby-site/src/templates/SamplePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const SamplePage: JaenTemplate = () => {
<h1>ChoiceField</h1>
<fields.ChoiceField
fieldName="choiceField"
initValue="a"
initValue="a" // optional
options={['a', 'b', 'c', 'd']}
onRenderPopover={(selection, options, select) => (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const ChoiceField: React.FC<ChoiceFieldProps> = ({
const register = () => dispatch(registerPageField({pageId, field}))
const unregister = () => dispatch(unregisterPageField({pageId, field}))

const isEditing = useAppSelector(state => state.options.isEditing)

const updatedValue = (useAppSelector(
pageFieldContentSelector(pageId, fieldName, block)
) as ChoiceBlock | undefined)?.option
Expand Down Expand Up @@ -107,6 +109,10 @@ const ChoiceField: React.FC<ChoiceFieldProps> = ({
}
}

if (!isEditing) {
return onRender(selection)
}

return (
<ChakraProvider>
<Popover trigger="hover">
Expand Down

0 comments on commit 4ee9231

Please sign in to comment.