Skip to content

add drag support for breadcrumbs#185995

Open
Kalmaegi wants to merge 6 commits intomicrosoft:mainfrom
Kalmaegi:add_breadcrumbs_drag_support
Open

add drag support for breadcrumbs#185995
Kalmaegi wants to merge 6 commits intomicrosoft:mainfrom
Kalmaegi:add_breadcrumbs_drag_support

Conversation

@Kalmaegi
Copy link
Copy Markdown
Contributor

Fix #182685

@Kalmaegi
Copy link
Copy Markdown
Contributor Author

@mjbvz @jrieken hi I found two question:

  1. When using drag breadcrumb, I found that if there is a file in the current breadcrumbs, this file is the currently active file, so dragging and turning on this function is not necessary
  2. When I drag and drop outside the edit area (e.g. file list, tab), what do we expect to happen

@Kalmaegi
Copy link
Copy Markdown
Contributor Author

Sorry I just saw the ci error, I will fix it

@Kalmaegi
Copy link
Copy Markdown
Contributor Author

@mjbvz @jrieken hi I would like to ask if this pr is qualified

@mjbvz mjbvz added this to the August 2023 milestone Jul 17, 2023
@mjbvz
Copy link
Copy Markdown
Collaborator

mjbvz commented Jul 17, 2023

@weartist Thanks for the PR! We need to wait for @jrieken's feedback. He's very busy right now so I've tentatively assigned this to be reviewed in August

@Kalmaegi
Copy link
Copy Markdown
Contributor Author

@weartist Thanks for the PR! We need to wait for @jrieken's feedback. He's very busy right now so I've tentatively assigned this to be reviewed in August

Thanks, I just thought maybe my request didn't follow the proper format or had some other basic mistake

@jrieken jrieken modified the milestones: August 2023, September 2023 Aug 18, 2023
dispose(): void { }
abstract equals(other: BreadcrumbsItem): boolean;
abstract render(container: HTMLElement): void;
abstract supportDrag(): boolean;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

An optional property might be better than a method, e.g supportsDrag?: boolean

container.classList.add('monaco-breadcrumb-item');
if (item.supportDrag()) {
container.draggable = true;
this._disposables.add(dom.addStandardDisposableListener(container, 'dragstart', e => this._onCrumbDrag(e)));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not OK. Everytime an item is rendered (which happens repeatedly) a listener is added but not disposed unless the breadcrumbs widget is disposed. The listeners must be managed with the lifecycle of the _renderItem-call.

Because of this and to avoid having too many listeners I recommended doing this:

  • only set draggable here
  • have only a single drag listener for the root dom node
  • have logic in the single listener to figure out what item is being dragged

}

const index = this._nodes.indexOf(event.target as HTMLDivElement);
const payload = event as any;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure I like this. Maybe have a special event type for DND and be more defensive, e.g return early when index is < 0 etc

}

private _willStartDragEvent(event: IBreadcrumbsItemEvent): void {
if (event.item instanceof FileItem === false) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this ever happen given how event is set up?

}

supportDrag(): boolean {
return false;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe outline items should also support DND. They can use the file-uri and the postion anchor, like file:///some/path.txt#L12:34 for line 12, column 34 of file some/path.txt

@jrieken jrieken removed this from the September 2023 milestone Sep 22, 2023
@Kalmaegi
Copy link
Copy Markdown
Contributor Author

@jrieken I'm sorry, due to some reasons, I haven't been able to continue coding in the past few months. May I kindly ask if it's possible for me to resume work on this pull request? If so, I would be happy to reorganize the code based on your suggestions.

@vivodi
Copy link
Copy Markdown

vivodi commented Dec 29, 2024

Any progress?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow dragging and dropping file entries in the breadcrumbs

4 participants