Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/@react-aria/interactions/src/usePress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ export function usePress(props: PressHookProps): PressResult {
]);

// Remove user-select: none in case component unmounts immediately after pressStart

useEffect(() => {
return () => {
if (!allowTextSelectionOnPress) {
Expand Down Expand Up @@ -935,7 +935,15 @@ function isOverTarget(point: EventPoint, target: Element) {

function shouldPreventDefaultDown(target: Element) {
// We cannot prevent default if the target is a draggable element.
return !(target instanceof HTMLElement) || !target.hasAttribute('draggable');
if (!(target instanceof HTMLElement)) {
return true;
}

if (target.tagName === 'A' && target.getAttribute('draggable') !== 'false') {
return false;
}
Comment on lines +942 to +944
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if target is a tag and doesn't have draggable="false" attr, we shouldn't prevent default to enable to drag the link


return !target.hasAttribute('draggable');
Copy link
Contributor Author

@mehm8128 mehm8128 Nov 28, 2024

Choose a reason for hiding this comment

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

Q: I think even if target element has draggable="false", target.hasAttribute('draggable') is true (because hasAttribute ignore its value), is it ok? or should we fix it to be !(target.getsAttribute('draggable') === "true");?

}

function shouldPreventDefaultUp(target: Element) {
Expand Down