From 138a8b09903fa4602e7594dcc150ccc7e850a849 Mon Sep 17 00:00:00 2001 From: Aleksandr Lesnenko <alxnddr@users.noreply.github.com> Date: Thu, 7 Jul 2022 18:05:19 +0400 Subject: [PATCH] fix parameter input loses value (#23750) --- .../metabase/components/TextWidget/TextWidget.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/metabase/components/TextWidget/TextWidget.tsx b/frontend/src/metabase/components/TextWidget/TextWidget.tsx index 234697d5268..5eb44d068ac 100644 --- a/frontend/src/metabase/components/TextWidget/TextWidget.tsx +++ b/frontend/src/metabase/components/TextWidget/TextWidget.tsx @@ -21,11 +21,6 @@ type State = { }; class TextWidget extends React.Component<Props, State> { - state: State = { - value: null, - isFocused: false, - }; - static defaultProps = { isEditing: false, commitImmediately: false, @@ -34,6 +29,11 @@ class TextWidget extends React.Component<Props, State> { constructor(props: Props) { super(props); + + this.state = { + value: props.value, + isFocused: false, + }; } static noPopover = true; @@ -43,7 +43,7 @@ class TextWidget extends React.Component<Props, State> { } UNSAFE_componentWillReceiveProps(nextProps: Props) { - if (nextProps.value !== this.state.value) { + if (nextProps.value !== this.props.value) { this.setState({ value: nextProps.value }, () => { // HACK: Address Safari rendering bug which causes https://github.com/metabase/metabase/issues/5335 forceRedraw(ReactDOM.findDOMNode(this)); -- GitLab