Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix d2l-list-item-drag-handle mouse interaction. #4238

Merged
merged 2 commits into from
Nov 6, 2023

Conversation

dbatiste
Copy link
Contributor

@dbatiste dbatiste commented Nov 3, 2023

DE55479

This PR fixes an issue where the d2l-list-item-drag-handle's up/down arrows are not clickable.

These arrows should be clickable with the mouse... but they are no longer. Clicking them causes the drag handle to revert its rendering back to drag mode (the dots icon).
image

For Chrome and Firefox, this appears to be a regression from this recent change: #4100.

For Safari, there's more - it also suffers from this long-standing terrible issue that Apple refuses to fix, where clicking a button that has focus will actually cause it to lose focus, which in this case, causes the drag-handle to toggle out of the d2l-button-move interaction.

@dbatiste dbatiste requested a review from bearfriend November 3, 2023 17:30
@dbatiste dbatiste requested a review from a team as a code owner November 3, 2023 17:30
Copy link
Contributor

github-actions bot commented Nov 3, 2023

Thanks for the PR! 🎉

We've deployed an automatic preview for this PR - you can see your changes here:

URL https://live.d2l.dev/prs/BrightspaceUI/core/pr-4238/

Note
The build needs to finish before your changes are deployed.
Changes to the PR will automatically update the instance.

@@ -335,6 +335,7 @@ export const ListItemDragDropMixin = superclass => class extends superclass {
opacity: 0;
}
:host([selected]) d2l-list-item-drag-handle,
d2l-list-item-drag-handle:hover,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I almost wonder if the pointer-events: none change in this PR is necessary with this change. I am a little worried about causing a regression on that fix if it's removed however.

@@ -72,6 +72,7 @@ class ListItemDragHandle extends LocalizeCoreElement(FocusMixin(RtlMixin(LitElem
:host {
display: flex;
margin: 0.25rem;
pointer-events: auto; /* required since its parent may set point-events: none; (see generic layout) */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes it so d2l-list-item-drag-handle's child d2l-button-move is clickable event though its parent sets pointer-events: none. Unfortunately this CSS could not be placed in the same spot next to it, since ::slotted() does not enable targeting elements deeper than their immediate children.

@@ -181,25 +182,6 @@ class ListItemDragHandle extends LocalizeCoreElement(FocusMixin(RtlMixin(LitElem
this.activateKeyboardMode();
}

_onKeyboardButtonFocusIn() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just renamed these handlers for consistency. I vaguely recall not doing it previously in effort to keep a previous PR smaller.

@@ -274,6 +275,10 @@ class ListItemDragHandle extends LocalizeCoreElement(FocusMixin(RtlMixin(LitElem

}

_onMoveButtonMouseDown(e) {
e.preventDefault();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needed to stop Safari from moving focus away from the button when it is clicked due to the frustrating position that Apple has taken.

Copy link
Contributor

@bearfriend bearfriend left a comment

Choose a reason for hiding this comment

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

Ugh. I hate how Safari has made this all so complicated again. I guess it's still better than the z-index stuff, though.

@dbatiste dbatiste merged commit 824ddb0 into main Nov 6, 2023
5 checks passed
@dbatiste dbatiste deleted the dbatiste/fix-drag-handle-mouse-interaction branch November 6, 2023 14:06
Copy link

🎉 This PR is included in version 2.160.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants