Rerender component preview on dropdown change

master
Kuba Orlik 9 months ago
parent 1b7e114460
commit c44047d21e

@ -15,6 +15,8 @@ import objectPath from "object-path";
export const actionName = "Components"; export const actionName = "Components";
const rerender = "this.closest('form').requestSubmit()";
const actions = { const actions = {
add_array_item: ( add_array_item: (
state: State, state: State,
@ -147,7 +149,10 @@ export default new (class ComponentsPage extends StatefulPage<State, typeof acti
<div> <div>
<label> <label>
{arg_path.at(-1)} {arg_path.at(-1)}
<select name={`$.args${this.printArgPath(arg_path)}`}> <select
name={`$.args${this.printArgPath(arg_path)}`}
onchange={rerender}
>
{arg.values.map((v) => ( {arg.values.map((v) => (
<option value={v} selected={value == v}> <option value={v} selected={value == v}>
{v} {v}
@ -191,7 +196,7 @@ export default new (class ComponentsPage extends StatefulPage<State, typeof acti
{arg.getTypeName() == "markdown" ? ( {arg.getTypeName() == "markdown" ? (
<textarea <textarea
name={`$.args${this.printArgPath(arg_path)}`} name={`$.args${this.printArgPath(arg_path)}`}
onblur="this.closest('form').requestSubmit()" onblur={rerender}
cols="70" cols="70"
> >
{value as string} {value as string}
@ -218,10 +223,7 @@ export default new (class ComponentsPage extends StatefulPage<State, typeof acti
<div class="resizable"> <div class="resizable">
{/*The below button has to be here in order for it to be the default behavior */} {/*The below button has to be here in order for it to be the default behavior */}
<input type="submit" value="Preview" /> <input type="submit" value="Preview" />
<select <select name="$.component" onchange={rerender}>
name="$.component"
onchange="this.closest('form').requestSubmit()"
>
{Object.entries(all_components).map(([name]) => ( {Object.entries(all_components).map(([name]) => (
<option value={name} selected={name == state.component}> <option value={name} selected={name == state.component}>
{name} {name}

Loading…
Cancel
Save