mirror of
https://github.com/discourse/discourse.git
synced 2025-04-25 14:24:33 +08:00
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:
parent
b06e31f8e7
commit
3eaf48aa37
app/assets
javascripts/discourse/app/components/sidebar
stylesheets/common/base
@ -1,9 +1,7 @@
|
|||||||
{{#if this.displaySection}}
|
{{#if this.displaySection}}
|
||||||
<div
|
<div
|
||||||
class={{concat
|
class={{concat-class
|
||||||
"sidebar-section-wrapper sidebar-section-"
|
(concat "sidebar-section-wrapper sidebar-section-" @sectionName)
|
||||||
@sectionName
|
|
||||||
" "
|
|
||||||
@class
|
@class
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -17,11 +17,15 @@
|
|||||||
@prefixValue={{link.icon}}
|
@prefixValue={{link.icon}}
|
||||||
@href={{link.value}}
|
@href={{link.value}}
|
||||||
@class={{link.linkDragCss}}
|
@class={{link.linkDragCss}}
|
||||||
{{draggable
|
{{(if
|
||||||
didStartDrag=link.didStartDrag
|
this.canReorder
|
||||||
didEndDrag=link.didEndDrag
|
(modifier
|
||||||
dragMove=link.dragMove
|
"draggable"
|
||||||
}}
|
didStartDrag=link.didStartDrag
|
||||||
|
didEndDrag=link.didEndDrag
|
||||||
|
dragMove=link.dragMove
|
||||||
|
)
|
||||||
|
)}}
|
||||||
/>
|
/>
|
||||||
{{else}}
|
{{else}}
|
||||||
<Sidebar::SectionLink
|
<Sidebar::SectionLink
|
||||||
@ -33,11 +37,15 @@
|
|||||||
@prefixType="icon"
|
@prefixType="icon"
|
||||||
@prefixValue={{link.icon}}
|
@prefixValue={{link.icon}}
|
||||||
@class={{link.linkDragCss}}
|
@class={{link.linkDragCss}}
|
||||||
{{draggable
|
{{(if
|
||||||
didStartDrag=link.didStartDrag
|
this.canReorder
|
||||||
didEndDrag=link.didEndDrag
|
(modifier
|
||||||
dragMove=link.dragMove
|
"draggable"
|
||||||
}}
|
didStartDrag=link.didStartDrag
|
||||||
|
didEndDrag=link.didEndDrag
|
||||||
|
dragMove=link.dragMove
|
||||||
|
)
|
||||||
|
)}}
|
||||||
/>
|
/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
@ -28,6 +28,12 @@ export default class SidebarUserCustomSections extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get canReorder() {
|
||||||
|
return document
|
||||||
|
.getElementsByTagName("html")[0]
|
||||||
|
.classList.contains("no-touch");
|
||||||
|
}
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
_refresh() {
|
_refresh() {
|
||||||
return ajax("/sidebar_sections.json", {}).then((json) => {
|
return ajax("/sidebar_sections.json", {}).then((json) => {
|
||||||
|
@ -23,7 +23,7 @@ export default class SectionLink {
|
|||||||
|
|
||||||
@bind
|
@bind
|
||||||
didStartDrag(e) {
|
didStartDrag(e) {
|
||||||
this.mouseY = e.targetTouches ? e.targetTouches[0].screenY : e.screenY;
|
this.mouseY = e.screenY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
@ -36,9 +36,7 @@ export default class SectionLink {
|
|||||||
|
|
||||||
@bind
|
@bind
|
||||||
dragMove(e) {
|
dragMove(e) {
|
||||||
const currentMouseY = e.targetTouches
|
const currentMouseY = e.screenY;
|
||||||
? e.targetTouches[0].screenY
|
|
||||||
: e.screenY;
|
|
||||||
const distance = currentMouseY - this.mouseY;
|
const distance = currentMouseY - this.mouseY;
|
||||||
if (!this.linkHeight) {
|
if (!this.linkHeight) {
|
||||||
this.linkHeight = document.getElementsByClassName(
|
this.linkHeight = document.getElementsByClassName(
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
.sidebar-section-link-prefix.icon,
|
.sidebar-section-link-prefix.icon,
|
||||||
.sidebar-section-link {
|
.sidebar-section-link {
|
||||||
background: none;
|
background: none;
|
||||||
color: var(--primary-low);
|
color: var(--primary-low-mid);
|
||||||
}
|
}
|
||||||
.sidebar-section-link.drag {
|
.sidebar-section-link.drag {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user