| React.TouchEvent) => {
e.preventDefault();
e.stopPropagation();
- if (this.props.onClear) {
- this.props.onClear();
+ if (onClearFromProps) {
+ onClearFromProps();
}
- this.input?.focus();
- };
+ inputRef.current?.focus();
+ }, [onClearFromProps]);
- render() {
- let clearableTooltipText = this.props.clearableTooltipText || '';
- if (!clearableTooltipText) {
- clearableTooltipText = (
-
- );
- }
+ const showClearButton = onClearFromProps && (clearableWithoutValue || (clearable && value));
- const {
- value,
- inputComponent,
- clearable,
- clearClassName,
- clearableWithoutValue,
- ...props
- } = this.props;
+ const inputElement = React.createElement(
+ inputComponent || 'input',
+ {
+ ...restProps,
+ ref: setInputRef,
+ defaultValue: value, // Only set the defaultValue since the real one will be updated using the 'useEffect' above
+ },
+ );
- Reflect.deleteProperty(props, 'delayInputUpdate');
- Reflect.deleteProperty(props, 'onClear');
- Reflect.deleteProperty(props, 'clearableTooltipText');
- Reflect.deleteProperty(props, 'channelId');
- Reflect.deleteProperty(props, 'clearClassName');
- Reflect.deleteProperty(props, 'tooltipPosition');
- Reflect.deleteProperty(props, 'forwardedRef');
-
- if (inputComponent !== AutosizeTextarea) {
- Reflect.deleteProperty(props, 'onHeightChange');
- Reflect.deleteProperty(props, 'onWidthChange');
- }
-
- const inputElement = React.createElement(
- inputComponent || 'input',
- {
- ...props,
- ref: this.setInputRef,
- defaultValue: value, // Only set the defaultValue since the real one will be updated using componentDidUpdate
- },
- );
-
- const showClearButton = this.props.onClear && (clearableWithoutValue || (clearable && value));
-
- return (
-
- {inputElement}
- {showClearButton && (
-
-
- );
- }
-}
+
+
+
+
+ )}
+
+ );
+});
type ForwardedProps = Omit, 'forwardedRef'>;
diff --git a/webapp/channels/src/components/user_group_popover/__snapshots__/user_group_popover.test.tsx.snap b/webapp/channels/src/components/user_group_popover/__snapshots__/user_group_popover.test.tsx.snap
index 96fb26a131..70b07b9369 100644
--- a/webapp/channels/src/components/user_group_popover/__snapshots__/user_group_popover.test.tsx.snap
+++ b/webapp/channels/src/components/user_group_popover/__snapshots__/user_group_popover.test.tsx.snap
@@ -187,10 +187,9 @@ exports[`component/user_group_popover should match snapshot 1`] = `
/>
-
-
+