mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-09 23:54:09 -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 {IFileTreeXTriggerEvents, FileTreeXEvent } from '../types'
|
||||
import _ from 'lodash'
|
||||
import { Notificar } from 'notificar'
|
||||
|
||||
interface IItemRendererXProps {
|
||||
/**
|
||||
@ -17,6 +18,7 @@ interface IItemRendererXProps {
|
||||
decorations: ClasslistComposite
|
||||
onClick: (ev: React.MouseEvent, item: FileEntry | Directory, type: ItemType) => 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
|
||||
@ -80,9 +82,10 @@ export class FileTreeItem extends React.Component<IItemRendererXProps & IItemRen
|
||||
onContextMenu={this.handleContextMenu}
|
||||
onClick={this.handleClick}
|
||||
onDoubleClick={this.handleDoubleClick}
|
||||
onDragStart={this.handleDragStartItem}
|
||||
// required for rendering context menus when opened through context menu button on keyboard
|
||||
ref={this.handleDivRef}
|
||||
draggable={false}>
|
||||
draggable={true}>
|
||||
|
||||
{!isNewPrompt && fileOrDir === 'directory' ?
|
||||
<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)
|
||||
}
|
||||
}
|
||||
|
||||
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