-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[url_launcher] Added draggable property [#102735] #5430
Conversation
allowing use of the Link widget in lists with mouse drag enabled.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). For more information, open the CLA check for this pull request. |
|
@ditman Ping on this review? |
|
Apologies! I'm going to bump this to @mdebbar, he knows the Mouad, do you mind taking a look? Thanks!! |
|
From triage: @mdebbar Ping on this review. |
mdebbar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks good to me. I would like for @ditman to take a look at the pubspec changes since I'm not very familiar with how plugin dependencies are supposed to be.
| url_launcher: | ||
| path: ../../url_launcher/ | ||
| dependency_overrides: | ||
| url_launcher_web: | ||
| path: ../ | ||
| url_launcher_platform_interface: | ||
| path: ../../url_launcher_platform_interface/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ditman I'm not qualified to review this part of the PR. Could you take a look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need to be reverted so we can merge and publish the affected packages in the correct order.
ditman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot merge this PR as is, because we now need to update version and CHANGELOG of the affected packages. Could you prepare a separate PR for each of the packages, so we can merge and publish them in order?
| _element.style | ||
| // Chrome | ||
| ..userDrag = 'none' | ||
| // Edge | ||
| ..setProperty('-webkit-user-drag', 'none'); | ||
| // Firefox | ||
| _element.draggable = false; | ||
| _dragSubscription = _element.onDragStart.listen((event) { | ||
| event.preventDefault(); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was checking caniuse.com, and it seems that:
- there's no unprefixed
user-dragproperty. Docs. - wouldn't
draggable = falsebe enough?
Also, if disabling drag in the element, is it necessary to stop the default drag event?
I think this method could be much simplified to be just _element.draggable = false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems you're close to being right. We started out with the styling approach since it allowed us to apply a global work-around in index.html (<style>a { -webkit-user-drag: none; }</style>). Probably just added user-drag since it was right there in html_dart2js.dart, and if it works, it's nicer than the -webkit- style. But it also seems that draggable works on both Chrome and Edge; however, I couldn't make it work on Firefox without preventDefault. In the end, I guess it's a matter of taste: Do you want style or properties for this? Do you want to wrap the drag subscription in some Firefox shim?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some tests, it seems that the only solution that seems to work the same across all platforms is preventDefault on the dragstart event. See:
If draggable=false, none of the browsers will trigger a dragstart event (as expected).
In Firefox, draggable=false works (it won't let you drag the Link), but it'll also start selecting from the text of the link as the user drags (which I guess is what you couldn't get to work?). This is a firefox quirk, but I couldn't find anything relevant in their bug tracker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(My second favorite version might be draggable=false and if the browser is firefox, prevent the selectstart event (draggable=false + no selectstart in the JSFiddle), which doesn't interfere with the selection from the outside as much as user-select in CSS does!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, what we couldn't get to work is the issue I linked to: links in a list. For that case preventing select start doesn't seem to be sufficient. But interactions with text selection should indeed probably also be considered.
| url_launcher: | ||
| path: ../../url_launcher/ | ||
| dependency_overrides: | ||
| url_launcher_web: | ||
| path: ../ | ||
| url_launcher_platform_interface: | ||
| path: ../../url_launcher_platform_interface/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need to be reverted so we can merge and publish the affected packages in the correct order.
We actually just do this one at a time; see https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages#changing-federated-plugins So the next step is to make just the platform interface PR, then once that lands, the implemenation package PR, then finally rebase this one. |
|
@kristoffer-zliide Are you planning on splitting out the platform interface PR, as described above? |
|
@stuartmorgan: Yeah, but I'm not sure if we've reached a conclusion on this: https://github.com/flutter/plugins/pull/5430/files#r896078916. I can make pull requests that adds draggable and preventDefault (ie, what's done for Firefox here: https://github.com/flutter/plugins/pull/5430/files#diff-77a04b3b00b00a4480b7d5e75e089dde7cca99ccebcc4f43e0e25d2bba5346e0R255), then you can always tweak it to your heart's content afterwards? |
|
@ditman You marked this as approved; what was your take on the resolution of that comment thread? |
@stuartmorgan let's go with the solution as implemented. I did some testing and indeed for cross-browser support, you need more than one approach, as @kristoffer-zliide correctly pointed out. Apologies I wasn't more clear in that regard! |
|
@kristoffer-zliide It sounds from the above like this was ready for a platform interface PR; are you still planning on splitting that out to move this forward? |
|
@stuartmorgan: here you go |
|
Status update from triage: blocked on resolving the breaking change issue in #6282. |
|
Status from triage: still blocked on #6282 |
|
Since this is still blocked on the other PR, I'm going to go ahead and mark this as a draft just to avoid having it come up in our triage queue. Once the blocking issue is resolved, this can be marked as ready for review again. |
|
Closing since #6282 is now closed. |
Allowing use of the Link widget in lists with mouse drag enabled.
In a desktop web browser, links are be default draggable. If they are put in e.g. a list, then that list cannot be scrolled by dragging it with the mouse. This PR makes it possible to disable this behavior.
Issues fixed: #102735
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.