diff --git a/packages/amis-core/src/renderers/Form.tsx b/packages/amis-core/src/renderers/Form.tsx index 69623a7601b..2cebbc82ecc 100644 --- a/packages/amis-core/src/renderers/Form.tsx +++ b/packages/amis-core/src/renderers/Form.tsx @@ -2351,13 +2351,7 @@ export class FormRenderer extends Form { super.componentDidMount(); if (this.props.autoFocus) { - const scoped = this.context as IScopedContext; - const inputs = scoped.getComponents(); - let focuableInput = find( - inputs, - input => input.focus - ) as ScopedComponentType; - focuableInput && setTimeout(() => focuableInput.focus!(), 200); + this.focus(); } } @@ -2368,6 +2362,16 @@ export class FormRenderer extends Form { super.componentWillUnmount(); } + focus() { + const scoped = this.context as IScopedContext; + const inputs = scoped.getComponents(); + let focuableInput = find( + inputs, + input => input.focus + ) as ScopedComponentType; + focuableInput && setTimeout(() => focuableInput.focus!(), 200); + } + doAction( action: ActionObject, data: object = this.props.store.data, diff --git a/packages/amis-core/src/utils/uncontrollable.tsx b/packages/amis-core/src/utils/uncontrollable.tsx index 82e67ae65d9..23f93fe44b6 100644 --- a/packages/amis-core/src/utils/uncontrollable.tsx +++ b/packages/amis-core/src/utils/uncontrollable.tsx @@ -6,7 +6,7 @@ export function uncontrollable< P extends { [propName: string]: any; } ->(arg: T, config: P, mapping?: any): T { +>(arg: T, config: P, mapping?: Array): T { const result = baseuncontrollable(arg, config, mapping); return hoistNonReactStatic(result, arg); } diff --git a/packages/amis-ui/scss/components/_quick-edit.scss b/packages/amis-ui/scss/components/_quick-edit.scss index 708f9197129..fe26a24f5f2 100644 --- a/packages/amis-ui/scss/components/_quick-edit.scss +++ b/packages/amis-ui/scss/components/_quick-edit.scss @@ -23,7 +23,7 @@ &:focus { position: relative; - &:after { + &:before { content: ''; left: 0; top: 0; diff --git a/packages/amis-ui/src/components/Button.tsx b/packages/amis-ui/src/components/Button.tsx index 6428b450d51..550b829a4c8 100644 --- a/packages/amis-ui/src/components/Button.tsx +++ b/packages/amis-ui/src/components/Button.tsx @@ -33,6 +33,7 @@ export interface ButtonProps classPrefix: string; classnames: ClassNamesFn; componentClass: React.ElementType; + tabIndex?: string; overrideClassName?: boolean; loading?: boolean; loadingClassName?: string; @@ -79,6 +80,7 @@ export class Button extends React.Component { overrideClassName, loadingConfig, testIdBuilder, + tabIndex, ...rest } = this.props; @@ -112,6 +114,7 @@ export class Button extends React.Component { style={style} title={title} disabled={disabled} + tabIndex={tabIndex} > {loading && !disabled && ( { } } -const EnhancedSelect = themeable( - localeable( - uncontrollable(Select, { - value: 'onChange' - }) - ) +const methods = ['focus', 'blur']; +const EnhancedSelect = uncontrollable( + themeable(localeable(Select, methods), methods), + { + value: 'onChange' + }, + methods ); export default EnhancedSelect; diff --git a/packages/amis/__tests__/renderers/Form/__snapshots__/inputTable.test.tsx.snap b/packages/amis/__tests__/renderers/Form/__snapshots__/inputTable.test.tsx.snap index 32bac504bd2..a9ce8691f53 100644 --- a/packages/amis/__tests__/renderers/Form/__snapshots__/inputTable.test.tsx.snap +++ b/packages/amis/__tests__/renderers/Form/__snapshots__/inputTable.test.tsx.snap @@ -438,7 +438,8 @@ exports[`Renderer:input table add 1`] = ` data-index="0" >