Skip to content

Commit

Permalink
fix(explore): reordering columns with dnd sometimes glitching (apache…
Browse files Browse the repository at this point in the history
…#16322)

* fix(explore): reordering columns with dnd sometimes glitching

* Fix metrics and filters popover being stale after reordering
  • Loading branch information
kgabryje authored Aug 18, 2021
1 parent 2c595b0 commit a547dcb
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ export const DndFilterSelect = (props: DndFilterSelectProps) => {
visible={newFilterPopoverVisible}
togglePopover={togglePopover}
closePopover={closePopover}
createNew
>
<div />
</AdhocFilterPopoverTrigger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ export const DndMetricSelect = (props: any) => {
visible={newMetricPopoverVisible}
togglePopover={togglePopover}
closePopover={closePopover}
createNew
>
<div />
</AdhocMetricPopoverTrigger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import React, { useMemo, useRef } from 'react';
import React, { useRef } from 'react';
import {
useDrag,
useDrop,
Expand Down Expand Up @@ -63,15 +63,11 @@ export default function OptionWrapper(
const ref = useRef<HTMLDivElement>(null);
const labelRef = useRef<HTMLDivElement>(null);

const item: OptionItemInterface = useMemo(
() => ({
dragIndex: index,
type,
}),
[index, type],
);
const [{ isDragging }, drag] = useDrag({
item,
item: {
type,
dragIndex: index,
},
collect: (monitor: DragSourceMonitor) => ({
isDragging: monitor.isDragging(),
}),
Expand Down Expand Up @@ -99,8 +95,8 @@ export default function OptionWrapper(
// Determine mouse position
const clientOffset = monitor.getClientOffset();
// Get pixels to the top
const hoverClientY = clientOffset?.y
? clientOffset?.y - hoverBoundingRect.top
const hoverClientY = clientOffset
? clientOffset.y - hoverBoundingRect.top
: 0;
// Only perform the move when the mouse has crossed half of the items height
// When dragging downwards, only move when the cursor is below 50%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ class AdhocFilterControl extends React.Component {
options={this.state.options}
onFilterEdit={this.onNewFilter}
partitionColumn={this.state.partitionColumn}
createNew
>
{trigger}
</AdhocFilterPopoverTrigger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ interface AdhocFilterPopoverTriggerProps {
datasource: Record<string, any>;
onFilterEdit: (editedFilter: AdhocFilter) => void;
partitionColumn?: string;
createNew?: boolean;
isControlledComponent?: boolean;
visible?: boolean;
togglePopover?: (visible: boolean) => void;
Expand Down Expand Up @@ -104,7 +103,7 @@ class AdhocFilterPopoverTrigger extends React.PureComponent<
defaultVisible={visible}
visible={visible}
onVisibleChange={togglePopover}
destroyTooltipOnHide={this.props.createNew}
destroyTooltipOnHide
>
{this.props.children}
</Popover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export type AdhocMetricPopoverTriggerProps = {
savedMetric: savedMetricType;
datasourceType: string;
children: ReactNode;
createNew?: boolean;
isControlledComponent?: boolean;
visible?: boolean;
togglePopover?: (visible: boolean) => void;
Expand Down Expand Up @@ -232,7 +231,7 @@ class AdhocMetricPopoverTrigger extends React.PureComponent<
visible={visible}
onVisibleChange={togglePopover}
title={popoverTitle}
destroyTooltipOnHide={this.props.createNew}
destroyTooltipOnHide
>
{this.props.children}
</Popover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ const MetricsControl = ({
datasource={datasource}
savedMetric={emptySavedMetric}
datasourceType={datasourceType}
createNew
>
{trigger}
</AdhocMetricPopoverTrigger>
Expand Down

0 comments on commit a547dcb

Please sign in to comment.