Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[fix] Move FeatureActionPanel to class component (#2067)
Igor Dykhtab53a6b757c29
diff --git a/src/components/src/editor/feature-action-panel.tsx b/src/components/src/editor/feature-action-panel.tsxindex 20f91ce81..42c6aa9e3 100644--- a/src/components/src/editor/feature-action-panel.tsx+++ b/src/components/src/editor/feature-action-panel.tsx@@ -18,7 +18,7 @@// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN// THE SOFTWARE.-import React, {useCallback, useState} from 'react';+import React, {useCallback, useState, Component, ComponentType} from 'react';import {useIntl} from 'react-intl';import ActionPanel, {ActionPanelItem} from '../common/action-panel';@@ -149,22 +149,27 @@ export function PureFeatureActionPanelFactory(): React.FC<FeatureActionPanelPropFeatureActionPanelFactory.deps = PureFeatureActionPanelFactory.deps;-export default function FeatureActionPanelFactory() {+export default function FeatureActionPanelFactory(): ComponentType<FeatureActionPanelProps> {const PureFeatureActionPanel = PureFeatureActionPanelFactory();- const ClickOutsideFeatureActionPanel: React.FC<FeatureActionPanelProps> = props => {- // @ts-ignore- ClickOutsideFeatureActionPanel.handleClickOutside = (e: Event) => {+ /**+ * FeatureActionPanel wrapped with a click-outside handler. Note that this needs to be a+ * class component, as react-onclickoutside does not handle functional components.+ */+ class ClickOutsideFeatureActionPanel extends Component<FeatureActionPanelProps> {+ handleClickOutside(e) {e.preventDefault();e.stopPropagation();- props.onClose?.();- };- return <PureFeatureActionPanel {...props} />;- };+ this.props.onClose?.();+ }++ render() {+ return <PureFeatureActionPanel {...this.props} />;+ }+ }const clickOutsideConfig = {- // @ts-ignore- handleClickOutside: () => ClickOutsideFeatureActionPanel.handleClickOutside+ handleClickOutside: () => ClickOutsideFeatureActionPanel.prototype.handleClickOutside};return onClickOutside(ClickOutsideFeatureActionPanel, clickOutsideConfig);