mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-08 01:13:27 +01:00
explicitly set active field by default
This commit is contained in:
parent
15b4a8e6fa
commit
b18fb6c361
4 changed files with 16 additions and 7 deletions
|
|
@ -100,7 +100,6 @@ export const ExtrudeOperation: OperationDescriptor<ExtrudeParams> = {
|
|||
|
||||
},
|
||||
|
||||
|
||||
form: [
|
||||
{
|
||||
type: 'number',
|
||||
|
|
@ -148,6 +147,8 @@ export const ExtrudeOperation: OperationDescriptor<ExtrudeParams> = {
|
|||
|
||||
],
|
||||
|
||||
defaultActiveField: 'face',
|
||||
|
||||
masking: [
|
||||
{
|
||||
id: 'CUT',
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ export interface OperationDescriptor<R> {
|
|||
previewGeomProvider?: (params: R) => OperationGeometryProvider,
|
||||
previewer?: any,
|
||||
form: FormDefinition | React.FunctionComponent,
|
||||
defaultActiveField: string,
|
||||
schema?: OperationSchema,
|
||||
onParamsUpdate?: (params, name, value) => void,
|
||||
masking?: {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export function Group({children}) {
|
|||
|
||||
export function formField(Control) {
|
||||
return function FormPrimitive({label, name, active, setActive, ...props}) {
|
||||
return <Field active={active} name={name} onFocus={setActive} onClick={setActive}>
|
||||
return <Field active={active} name={name} onClick={setActive}>
|
||||
<Label>{label || camelCaseSplitToStr(name)}</Label>
|
||||
<Control {...props} />
|
||||
</Field>;
|
||||
|
|
@ -52,10 +52,7 @@ export function attachToForm(Control): any {
|
|||
const fullPath = [...formPath, name];
|
||||
const fullPathFlatten = flattenPath(fullPath);
|
||||
|
||||
const onChange = value => {
|
||||
console.log(fullPath + " : " + value);
|
||||
formEdit.onChange(fullPath, value);
|
||||
}
|
||||
const onChange = value => formEdit.onChange(fullPath, value);
|
||||
const setActive = (isActive) => formEdit.setActive(fullPathFlatten, isActive);
|
||||
|
||||
const value = params[name];
|
||||
|
|
|
|||
|
|
@ -89,8 +89,18 @@ export function activate(ctx: ApplicationContext) {
|
|||
if (old !== null && old.requestKey !== curr?.requestKey) {
|
||||
disposerList.call();
|
||||
disposerList = createFunctionList();
|
||||
state$.next({});
|
||||
}
|
||||
|
||||
const newState: WizardState = {};
|
||||
|
||||
if (curr) {
|
||||
const op = ctx.operationService.get(curr.type);
|
||||
if (op.defaultActiveField) {
|
||||
newState.activeParam = op.defaultActiveField;
|
||||
}
|
||||
}
|
||||
|
||||
state$.next(newState);
|
||||
})
|
||||
|
||||
const updateParams = mutator => workingRequest$.update((req: WorkingRequest) => produce(req, draft => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue