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: Switch tab on drag hover #21648

Merged
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 @@ -42,6 +42,7 @@ const propTypes = {
index: PropTypes.number.isRequired,
style: PropTypes.object,
onDrop: PropTypes.func,
onHover: PropTypes.func,
editMode: PropTypes.bool.isRequired,
useEmptyDragPreview: PropTypes.bool,

Expand All @@ -61,6 +62,7 @@ const defaultProps = {
disableDragDrop: false,
children() {},
onDrop() {},
onHover() {},
orientation: 'row',
useEmptyDragPreview: false,
isDragging: false,
Expand Down
2 changes: 2 additions & 0 deletions superset-frontend/src/dashboard/components/dnd/handleHover.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ function handleHover(props, monitor, Component) {
return;
}

Component?.props?.onHover();

Component.setState(() => ({
dropIndicator: dropPosition,
}));
Expand Down
10 changes: 10 additions & 0 deletions superset-frontend/src/dashboard/components/gridComponents/Tab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const propTypes = {
depth: PropTypes.number.isRequired,
renderType: PropTypes.oneOf([RENDER_TAB, RENDER_TAB_CONTENT]).isRequired,
onDropOnTab: PropTypes.func,
onHoverTab: PropTypes.func,
editMode: PropTypes.bool.isRequired,
canEdit: PropTypes.bool.isRequired,

Expand All @@ -64,6 +65,7 @@ const defaultProps = {
availableColumnCount: 0,
columnWidth: 0,
onDropOnTab() {},
onHoverTab() {},
onResizeStart() {},
onResize() {},
onResizeStop() {},
Expand Down Expand Up @@ -95,6 +97,7 @@ class Tab extends React.PureComponent {
super(props);
this.handleChangeText = this.handleChangeText.bind(this);
this.handleDrop = this.handleDrop.bind(this);
this.handleOnHover = this.handleOnHover.bind(this);
this.handleTopDropTargetDrop = this.handleTopDropTargetDrop.bind(this);
this.handleChangeTab = this.handleChangeTab.bind(this);
}
Expand Down Expand Up @@ -123,6 +126,10 @@ class Tab extends React.PureComponent {
this.props.onDropOnTab(dropResult);
}

handleOnHover() {
this.props.onHoverTab();
}

handleTopDropTargetDrop(dropResult) {
if (dropResult) {
this.props.handleComponentDrop({
Expand Down Expand Up @@ -216,6 +223,7 @@ class Tab extends React.PureComponent {
depth={depth} // see isValidChild.js for why tabs don't increment child depth
index={componentIndex}
onDrop={this.handleDrop}
onHover={this.handleOnHover}
availableColumnCount={availableColumnCount}
columnWidth={columnWidth}
onResizeStart={onResizeStart}
Expand All @@ -234,6 +242,7 @@ class Tab extends React.PureComponent {
index={tabComponent.children.length}
depth={depth}
onDrop={this.handleDrop}
onHover={this.handleOnHover}
editMode
className="empty-droptarget"
>
Expand Down Expand Up @@ -263,6 +272,7 @@ class Tab extends React.PureComponent {
index={index}
depth={depth}
onDrop={this.handleDrop}
onHover={this.handleOnHover}
editMode={editMode}
>
{({ dropIndicatorProps, dragSourceRef }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ export class Tabs extends React.PureComponent {
availableColumnCount={availableColumnCount}
columnWidth={columnWidth}
onDropOnTab={this.handleDropOnTab}
onHoverTab={() => this.handleClickTab(tabIndex)}
isFocused={activeKey === tabId}
isHighlighted={
activeKey !== tabId && tabsToHighlight?.includes(tabId)
Expand Down