some comments
This commit is contained in:
parent
d2fb973e1d
commit
9385146d56
|
@ -328,6 +328,8 @@ export const SquigglePlayground: FC<PlaygroundProps> = ({
|
||||||
<StyledTab.Panel>
|
<StyledTab.Panel>
|
||||||
<ViewSettings
|
<ViewSettings
|
||||||
register={
|
register={
|
||||||
|
// This is dangerous, but doesn't cause any problems.
|
||||||
|
// I tried to make `ViewSettings` generic (to allow it to accept any extension of a settings schema), but it didn't work.
|
||||||
register as unknown as UseFormRegister<
|
register as unknown as UseFormRegister<
|
||||||
yup.InferType<typeof viewSettingsSchema>
|
yup.InferType<typeof viewSettingsSchema>
|
||||||
>
|
>
|
||||||
|
|
|
@ -33,6 +33,7 @@ const ItemSettingsModal: React.FC<Props & { close: () => void }> = ({
|
||||||
const { register, watch } = useForm({
|
const { register, watch } = useForm({
|
||||||
resolver: yupResolver(viewSettingsSchema),
|
resolver: yupResolver(viewSettingsSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
|
// this is a mess and should be fixed
|
||||||
showEditor: true, // doesn't matter
|
showEditor: true, // doesn't matter
|
||||||
chartHeight: mergedSettings.height,
|
chartHeight: mergedSettings.height,
|
||||||
showSummary: mergedSettings.distributionPlotSettings.showSummary,
|
showSummary: mergedSettings.distributionPlotSettings.showSummary,
|
||||||
|
|
|
@ -22,6 +22,9 @@ export const VariableBox: React.FC<VariableBoxProps> = ({
|
||||||
}) => {
|
}) => {
|
||||||
const { setSettings, getSettings, getMergedSettings } =
|
const { setSettings, getSettings, getMergedSettings } =
|
||||||
useContext(ViewerContext);
|
useContext(ViewerContext);
|
||||||
|
|
||||||
|
// Since ViewerContext doesn't keep the actual settings, VariableBox won't rerender when setSettings is called.
|
||||||
|
// So we use `forceUpdate` to force rerendering.
|
||||||
const [_, forceUpdate] = useReducer((x) => x + 1, 0);
|
const [_, forceUpdate] = useReducer((x) => x + 1, 0);
|
||||||
|
|
||||||
const settings = getSettings(path);
|
const settings = getSettings(path);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user