some comments

This commit is contained in:
Vyacheslav Matyukhin 2022-07-22 23:51:54 +04:00
parent d2fb973e1d
commit 9385146d56
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C
3 changed files with 6 additions and 0 deletions

View File

@ -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>
> >

View File

@ -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,

View File

@ -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);