angular / angular/components

feat(cdkDrag): cdkDragExclude to mark a part of the tree as should not be

Ouverte
#29,827 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
area: cdk/drag-drop feature P4
Langage dominant
TypeScript
Étoiles
25k
Forks
6.8k
Merge moyen
1 j 8 h
PR mergées (30 j)
91

Description

### Feature Description

Create a Directive (tentatively named cdkDragExclude) that when applied to an element does the effective inverse of cdkDragHandle. That element and it's children will not be able to be dragged/not cause the cdkDrag'ed item to be dragged.

As an alternative to a new directive, It should be possible to accomplish the same goal without adding a new directive by making it so that a cdkDragHandle that's disabled, inside another cdkDragHandle, (or a cdkDrag that's disabled inside another cdkDrag), will result in that element being un-dragable. As it stands, a cdkDrag in a cdkDrag will result in the parent one being moved, and a cdkDragHandle in a cdkDragHandle has no impact. I'm not sure how changing the interactions like that needs to be considered from an API stability point, and I'm also unsure if that's an acceptable option as it is not very intuitive.

### Use Case

This is specifically targeted at parts of a component/component tree that have interactive elements of their own. (or where one might wish there to be interactivity)

- Text inputs: Unable to highlight the text on an input with a mouse.
- Text Area: Unable to change the size of a text area input as dragging the anchor in the bottom right corner results in the node moving instead
- Sliders: Sliders become difficult/nearly impossible to use
- Simply Highlighting text: Highlighting text in an element becomes difficult as the node itself will move instead of allowing the text to be selected.

This was discussed previously in #12929 and there was a response of "You can use the cdkDragHandle directive to configure which element should be draggable". The complexity of certain draggable components makes this nearly untenable under some circumstances unfortunately.

If I need to disable dragging on a single sibling element, I have to add cdkDragHandle to all other siblings of that element, all siblings of the element's parent, the parents parent, and so on until I reach the root dragable element itself. That process alone does not account for any margin on the element, which would have to be replaced with margin elements that also have cdkDragHandle, or other such hacks.

This only gets more complicated and unweildly the more elements you have that require disabling of the dragging.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par lire les directives existantes cdkDrag et cdkDragHandle ainsi que la discussion précédente dans l’issue #12929. Comparez la directive cdkDragExclude proposée avec les handles ou drags imbriqués désactivés, puis définissez l’API et le comportement d’interaction nécessaires pour empêcher le glisser-déposer à l’intérieur des éléments exclus tout en préservant le glisser-déposer normal ailleurs.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
frontend
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
32/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.