Skip to content

Commit

Permalink
#2108 - Input fields in some modals lose focus when typing (#2117)
Browse files Browse the repository at this point in the history
Co-authored-by: Stanislav Permiakov <Stanislav.Permiakov@primark.onmicrosoft.com>
  • Loading branch information
St-Permiakov and Stanislav Permiakov authored Jan 23, 2023
1 parent a97f978 commit cf174f6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/ketcher-react/src/script/ui/component/form/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ function componentMap(props: Props) {
return type === 'radio' ? FieldSet : Select
}

const AnyComponentWithRef = React.forwardRef(
({ Component, ...props }: any, ref) => <Component {...props} innerRef={ref} />
)

class Input extends PureComponent<
Props & { innerRef: React.Ref<HTMLInputElement> }
> {
Expand All @@ -351,14 +355,10 @@ class Input extends PureComponent<

render() {
const { children, onChange, ...restProps } = this.props
const Component = this.component

const ComponentWithRef = React.forwardRef((props, ref) => (
<Component {...props} innerRef={ref} />
))

return (
<ComponentWithRef
<AnyComponentWithRef
Component={this.component}
ref={this.props.innerRef}
{...this.ctrl}
{...restProps}
Expand Down

0 comments on commit cf174f6

Please sign in to comment.