Skip to content

Commit

Permalink
fix scrolling to top of form when switching from undefined value to s…
Browse files Browse the repository at this point in the history
…ome value
  • Loading branch information
andreiggr committed Feb 3, 2023
1 parent baa5b83 commit 877d385
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/Widgets/ThemePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@ import { Form } from 'semantic-ui-react';
import { Grid, Button } from 'semantic-ui-react';

const ThemePicker = (props) => {
const { id, title, required, value, onChange, colors, className } = props;
const {
id,
title,
required,
defaultValue = 'no-theme',
value,
onChange,
colors,
className,
} = props;

React.useEffect(() => {
if (!props.value && props.default) {
props.onChange(props.id, props.default);
if (!value && defaultValue) {
onChange(id, defaultValue);
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const applyConfig = (config) => {
config.widgets.widget.theme_picker = ThemePickerWidget;

config.settings.themeColors = [
{ value: undefined, title: 'No theme' },
{ value: 'no-theme', title: 'No theme' },
{ value: 'primary', title: 'Primary' },
{ value: 'secondary', title: 'Secondary' },
{ value: 'tertiary', title: 'Tertiary' },
Expand Down

0 comments on commit 877d385

Please sign in to comment.