Skip to content

Conversation

@ntacheva
Copy link
Contributor

No description provided.

@ntacheva ntacheva added the merge-to-production Use this label to get a comment to choose whether to merge the PR to production label Nov 29, 2024
@ntacheva ntacheva self-assigned this Nov 29, 2024
@ntacheva ntacheva requested review from a team as code owners November 29, 2024 11:51
@github-actions
Copy link
Contributor

Hello @ntacheva,

Check the below option if you would like to automatically generate PR to production. The automation uses the branch for the cherry-pick, and then will delete the branch. Please, do not delete it manually.

  • create PR to production

@ntacheva ntacheva merged commit 469b130 into master Nov 29, 2024
1 check passed
@github-actions
Copy link
Contributor

Here you are the link to your PR to production: 2591

@github-actions github-actions bot deleted the treeview-kb-custom-target branch November 29, 2024 14:20
Copy link
Contributor

@ikoevska ikoevska left a comment

Choose a reason for hiding this comment

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

In addition to the inline comments, consider adding a See Also section at the bottom.

@@ -0,0 +1,206 @@
---
title: Drag TreeView Items to a Custom Target
description: How to support draging and reordering items inside the TreeView but also allow dragging and dropping items outside the component to a custom target
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: How to support draging and reordering items inside the TreeView but also allow dragging and dropping items outside the component to a custom target
description: How to support dragging and reordering items inside the TreeView but also allow dragging and dropping items outside the component to a custom target.


## Description

I have a TreeView that allows dragging and reordering items inside the component. I want to also allow dragging items outside the TreeView, so the users can drop them on custom target. How to achieve that?
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
I have a TreeView that allows dragging and reordering items inside the component. I want to also allow dragging items outside the TreeView, so the users can drop them on custom target. How to achieve that?
I have a TreeView that allows dragging and reordering items inside the component. I want to also allow dragging items outside the TreeView, so the users can drop them on a custom target. How to achieve that?

To allow dragging outside the TreeView and dropping on a custom target, follow these steps:

1. Handle the [`OnDragStart`]({%slug treeview-events%}#drag-events) event of the TreeView to get the item that the user started dragging.
1. Handle the [`@onpointerup`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerup_event) event of your custom target to add the TreeView inside as needed. Based on product specifics, the TreeView internally does not use draggable events, it uses pointer events to handle the dragging. Therefore, `@ondrop` of your custom target will not fire when dragging a TreeView item in it as the component expects a subsequent pointer event. Use the `@onpointerup` instead of `@ondrop`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, external links should open in a new window with the <a href="" target="_blank"> syntax.

1. Handle the [`OnDragStart`]({%slug treeview-events%}#drag-events) event of the TreeView to get the item that the user started dragging.
1. Handle the [`@onpointerup`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerup_event) event of your custom target to add the TreeView inside as needed. Based on product specifics, the TreeView internally does not use draggable events, it uses pointer events to handle the dragging. Therefore, `@ondrop` of your custom target will not fire when dragging a TreeView item in it as the component expects a subsequent pointer event. Use the `@onpointerup` instead of `@ondrop`.
1. Change the icon in the drag clue when the user drags over the custom target to indicate it is an allowed target. Once the [Drag Clue Template](https://feedback.telerik.com/blazor/1501043-drag-clue-template) is available, you may use it to change the rendering as needed. At the time of writing, changing the icon is only possible with CSS. For that purpose:
1. Handle [`@onpointerenter`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerenter_event) and [`@onpointerout`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerout_event) events of the custom target to detect when the user drags the item over it.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
1. Handle [`@onpointerenter`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerenter_event) and [`@onpointerout`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerout_event) events of the custom target to detect when the user drags the item over it.
1. Handle the [`@onpointerenter`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerenter_event) and [`@onpointerout`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerout_event) events of the custom target to detect when the user drags the item over it.

1. Raise and drop a flag based on the pointer position.
1. Conditionally apply custom CSS to change the drop clue icon based on the flag.

>caption Draggable Treeview that allows dropping items in a custom target
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
>caption Draggable Treeview that allows dropping items in a custom target
>caption Draggable Treeview that allows dropping items in a custom target

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

Labels

merge-to-production Use this label to get a comment to choose whether to merge the PR to production

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants