From e743ce7135235b2d0def403fa330f663ea1a2667 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Wed, 30 Sep 2020 23:12:51 -0700 Subject: [PATCH] fix: SpatialControl popover won't open (#11127) Recently a change related to emotion styling not properly working through react-bootstrap's popover broke the SpatialControl. This PR makes SpatialControl use antd's equivalent, and addresses the issue as a result: emotion's styling context is preserved through this superior popover. --- .../src/components/Popover/index.tsx | 23 ++++ .../components/controls/SpatialControl.jsx | 130 ++++++++---------- 2 files changed, 78 insertions(+), 75 deletions(-) create mode 100644 superset-frontend/src/components/Popover/index.tsx diff --git a/superset-frontend/src/components/Popover/index.tsx b/superset-frontend/src/components/Popover/index.tsx new file mode 100644 index 0000000000000..9cec64080b024 --- /dev/null +++ b/superset-frontend/src/components/Popover/index.tsx @@ -0,0 +1,23 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { Popover } from 'src/common/components'; + +// Eventually Popover can be wrapped and customized in this file +// for now we're just redirecting +export default Popover; diff --git a/superset-frontend/src/explore/components/controls/SpatialControl.jsx b/superset-frontend/src/explore/components/controls/SpatialControl.jsx index 073148be9560b..5c34ec3ca685c 100644 --- a/superset-frontend/src/explore/components/controls/SpatialControl.jsx +++ b/superset-frontend/src/explore/components/controls/SpatialControl.jsx @@ -18,11 +18,11 @@ */ import React from 'react'; import PropTypes from 'prop-types'; -import { Row, Col, OverlayTrigger, Popover } from 'react-bootstrap'; -import Button from 'src/components/Button'; +import { Row, Col } from 'react-bootstrap'; import { t } from '@superset-ui/core'; import Label from 'src/components/Label'; +import Popover from 'src/components/Popover'; import PopoverSection from 'src/components/PopoverSection'; import Checkbox from 'src/components/Checkbox'; import ControlHeader from '../ControlHeader'; @@ -108,10 +108,6 @@ export default class SpatialControl extends React.Component { this.setState({ type }, this.onChange); } - close() { - this.refs.trigger.hide(); - } - toggleCheckbox() { this.setState( prevState => ({ reverseCheckbox: !prevState.reverseCheckbox }), @@ -164,68 +160,56 @@ export default class SpatialControl extends React.Component { ); } - renderPopover() { + renderPopoverContent() { return ( - -
- - - - Longitude - {this.renderSelect('lonCol', spatialTypes.latlong)} - - - Latitude - {this.renderSelect('latCol', spatialTypes.latlong)} - - - - - - - {t('Column')} - {this.renderSelect('lonlatCol', spatialTypes.delimited)} - - {this.renderReverseCheckbox()} - - - - - - Column - {this.renderSelect('geohashCol', spatialTypes.geohash)} - - {this.renderReverseCheckbox()} - - -
- -
-
-
+
+ + + + Longitude + {this.renderSelect('lonCol', spatialTypes.latlong)} + + + Latitude + {this.renderSelect('latCol', spatialTypes.latlong)} + + + + + + + {t('Column')} + {this.renderSelect('lonlatCol', spatialTypes.delimited)} + + {this.renderReverseCheckbox()} + + + + + + Column + {this.renderSelect('geohashCol', spatialTypes.geohash)} + + {this.renderReverseCheckbox()} + + +
); } @@ -233,17 +217,13 @@ export default class SpatialControl extends React.Component { return (
- - +
); }