FIX: disable reorder links on touch screens (#20769)

This feature causes troubles on touch screens like phones and tablets. Right now, we would like to limit it to mouse and touchpads.

/t/94351
This commit is contained in:
Krzysztof Kotlarek 2023-03-22 13:34:19 +11:00 committed by GitHub
parent b06e31f8e7
commit 3eaf48aa37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 19 deletions

View File

@ -1,9 +1,7 @@
{{#if this.displaySection}}
<div
class={{concat
"sidebar-section-wrapper sidebar-section-"
@sectionName
" "
class={{concat-class
(concat "sidebar-section-wrapper sidebar-section-" @sectionName)
@class
}}
>

View File

@ -17,11 +17,15 @@
@prefixValue={{link.icon}}
@href={{link.value}}
@class={{link.linkDragCss}}
{{draggable
{{(if
this.canReorder
(modifier
"draggable"
didStartDrag=link.didStartDrag
didEndDrag=link.didEndDrag
dragMove=link.dragMove
}}
)
)}}
/>
{{else}}
<Sidebar::SectionLink
@ -33,11 +37,15 @@
@prefixType="icon"
@prefixValue={{link.icon}}
@class={{link.linkDragCss}}
{{draggable
{{(if
this.canReorder
(modifier
"draggable"
didStartDrag=link.didStartDrag
didEndDrag=link.didEndDrag
dragMove=link.dragMove
}}
)
)}}
/>
{{/if}}
{{/each}}

View File

@ -28,6 +28,12 @@ export default class SidebarUserCustomSections extends Component {
});
}
get canReorder() {
return document
.getElementsByTagName("html")[0]
.classList.contains("no-touch");
}
@bind
_refresh() {
return ajax("/sidebar_sections.json", {}).then((json) => {

View File

@ -23,7 +23,7 @@ export default class SectionLink {
@bind
didStartDrag(e) {
this.mouseY = e.targetTouches ? e.targetTouches[0].screenY : e.screenY;
this.mouseY = e.screenY;
}
@bind
@ -36,9 +36,7 @@ export default class SectionLink {
@bind
dragMove(e) {
const currentMouseY = e.targetTouches
? e.targetTouches[0].screenY
: e.screenY;
const currentMouseY = e.screenY;
const distance = currentMouseY - this.mouseY;
if (!this.linkHeight) {
this.linkHeight = document.getElementsByClassName(

View File

@ -20,7 +20,7 @@
.sidebar-section-link-prefix.icon,
.sidebar-section-link {
background: none;
color: var(--primary-low);
color: var(--primary-low-mid);
}
.sidebar-section-link.drag {
font-weight: bold;