Skip to content

fix(cdk/drag-drop): don't disable native dragging on inactive handles - #20991

Merged
wagnermaciel merged 1 commit into
angular:masterfrom
crisbeto:20974/drag-drop-disabled-handle
Nov 17, 2020
Merged

fix(cdk/drag-drop): don't disable native dragging on inactive handles#20991
wagnermaciel merged 1 commit into
angular:masterfrom
crisbeto:20974/drag-drop-disabled-handle

Conversation

@crisbeto

@crisbeto crisbeto commented Nov 9, 2020

Copy link
Copy Markdown
Member

Currently we disable native drag interactions on handles once when they're registered, however this can block scrolling on mobile devices if the handle is inactive (either it is disabled or the drag element is disabled).

These changes toggle the state dynamically depending on the active state.

Fixes #20974.

Currently we disable native drag interactions on handles once when they're registered,
however this can block scrolling on mobile devices if the handle is inactive (either it
is disabled or the drag element is disabled).

These changes toggle the state dynamically depending on the active state.

Fixes angular#20974.
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release labels Nov 9, 2020
@google-cla google-cla Bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 9, 2020
this._disabledHandles.delete(handle);
if (this._disabledHandles.has(handle)) {
this._disabledHandles.delete(handle);
toggleNativeDragInteractions(handle, this.disabled);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this say false instead of this.disabled?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, the handle should stay disabled if it is enabled while the drag item is disabled.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Then should it also use this.disabled in disableHandle? seems odd that the methods aren't mirrored

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No since disableHandle only disables the handle, not the entire draggable item. A handle is considered "inactive" if either it is disabled or the item is disabled. This might be slightly confusing since toggleNativeDragInteractions(true) means that interactions should be enabled which is true when dragging is disabled.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok I think I understand it, just a little confusing at first sight

@mmalerba mmalerba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

this._disabledHandles.delete(handle);
if (this._disabledHandles.has(handle)) {
this._disabledHandles.delete(handle);
toggleNativeDragInteractions(handle, this.disabled);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok I think I understand it, just a little confusing at first sight

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Nov 10, 2020
@wagnermaciel
wagnermaciel merged commit f133210 into angular:master Nov 17, 2020
wagnermaciel pushed a commit that referenced this pull request Nov 17, 2020
…#20991)

Currently we disable native drag interactions on handles once when they're registered,
however this can block scrolling on mobile devices if the handle is inactive (either it
is disabled or the drag element is disabled).

These changes toggle the state dynamically depending on the active state.

Fixes #20974.

(cherry picked from commit f133210)
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(drag-drop): scrolling on mobile blocked for disabled drag handle

3 participants