mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix an issue where drag and drop object names is not working. #5761
This commit is contained in:
parent
c2acaa2fc8
commit
f3bb4776e4
@ -4,6 +4,7 @@ import { ClasslistComposite } from 'aspen-decorations'
|
|||||||
import { Directory, FileEntry, IItemRendererProps, ItemType, PromptHandle, RenamePromptHandle, FileType, FileOrDir} from 'react-aspen'
|
import { Directory, FileEntry, IItemRendererProps, ItemType, PromptHandle, RenamePromptHandle, FileType, FileOrDir} from 'react-aspen'
|
||||||
import {IFileTreeXTriggerEvents, FileTreeXEvent } from '../types'
|
import {IFileTreeXTriggerEvents, FileTreeXEvent } from '../types'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
import { Notificar } from 'notificar'
|
||||||
|
|
||||||
interface IItemRendererXProps {
|
interface IItemRendererXProps {
|
||||||
/**
|
/**
|
||||||
@ -17,6 +18,7 @@ interface IItemRendererXProps {
|
|||||||
decorations: ClasslistComposite
|
decorations: ClasslistComposite
|
||||||
onClick: (ev: React.MouseEvent, item: FileEntry | Directory, type: ItemType) => void
|
onClick: (ev: React.MouseEvent, item: FileEntry | Directory, type: ItemType) => void
|
||||||
onContextMenu: (ev: React.MouseEvent, item: FileEntry | Directory) => void
|
onContextMenu: (ev: React.MouseEvent, item: FileEntry | Directory) => void
|
||||||
|
events: Notificar<FileTreeXEvent>
|
||||||
}
|
}
|
||||||
|
|
||||||
// DO NOT EXTEND FROM PureComponent!!! You might miss critical changes made deep within `item` prop
|
// DO NOT EXTEND FROM PureComponent!!! You might miss critical changes made deep within `item` prop
|
||||||
@ -80,9 +82,10 @@ export class FileTreeItem extends React.Component<IItemRendererXProps & IItemRen
|
|||||||
onContextMenu={this.handleContextMenu}
|
onContextMenu={this.handleContextMenu}
|
||||||
onClick={this.handleClick}
|
onClick={this.handleClick}
|
||||||
onDoubleClick={this.handleDoubleClick}
|
onDoubleClick={this.handleDoubleClick}
|
||||||
|
onDragStart={this.handleDragStartItem}
|
||||||
// required for rendering context menus when opened through context menu button on keyboard
|
// required for rendering context menus when opened through context menu button on keyboard
|
||||||
ref={this.handleDivRef}
|
ref={this.handleDivRef}
|
||||||
draggable={false}>
|
draggable={true}>
|
||||||
|
|
||||||
{!isNewPrompt && fileOrDir === 'directory' ?
|
{!isNewPrompt && fileOrDir === 'directory' ?
|
||||||
<i className={cn('directory-toggle', isDirExpanded ? 'open' : '')} />
|
<i className={cn('directory-toggle', isDirExpanded ? 'open' : '')} />
|
||||||
@ -164,4 +167,14 @@ export class FileTreeItem extends React.Component<IItemRendererXProps & IItemRen
|
|||||||
onDoubleClick(ev, item as FileEntry, itemType)
|
onDoubleClick(ev, item as FileEntry, itemType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private handleDragStartItem = (e: React.DragEvent) => {
|
||||||
|
const { item, itemType, events } = this.props
|
||||||
|
if (itemType === ItemType.File || itemType === ItemType.Directory) {
|
||||||
|
const ref = FileTreeItem.itemIdToRefMap.get(item.id)
|
||||||
|
if (ref) {
|
||||||
|
events.dispatch(FileTreeXEvent.onTreeEvents, e, 'dragstart', item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user