Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(explore): reordering columns with dnd sometimes glitching #16322

Merged
merged 2 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
},
Comment on lines -66 to +70
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears we're a few versions behind react-dnd (now on 14; we're on 11). Apparently the deps can now be given as a param after spec:

image

https://react-dnd.github.io/react-dnd/docs/api/use-drag

Might be a good TODO for when we bump this the next time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know!

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