mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 15:05:24 +08:00
FEATURE: Automatically select share URL (#16025)
The URL will be selected for easy copying immediately after the share popup shows up.
This commit is contained in:
parent
582091a698
commit
e0b683f98e
|
@ -10,6 +10,7 @@ import { bufferedProperty } from "discourse/mixins/buffered-content";
|
|||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||
import I18n from "I18n";
|
||||
import Category from "discourse/models/category";
|
||||
import { scheduleOnce } from "@ember/runloop";
|
||||
|
||||
export default Controller.extend(
|
||||
ModalFunctionality,
|
||||
|
@ -32,6 +33,17 @@ export default Controller.extend(
|
|||
if (this.model && this.model.read_restricted) {
|
||||
this.restrictedGroupWarning();
|
||||
}
|
||||
|
||||
scheduleOnce("afterRender", this, this.selectUrl);
|
||||
},
|
||||
|
||||
selectUrl() {
|
||||
const input = document.querySelector("input.invite-link");
|
||||
if (input && !this.site.mobileView) {
|
||||
// if the input is auto-focused on mobile, iOS requires two taps of the copy button
|
||||
input.setSelectionRange(0, this.url.length);
|
||||
input.focus();
|
||||
}
|
||||
},
|
||||
|
||||
@discourseComputed("post.shareUrl", "topic.shareUrl")
|
||||
|
@ -49,9 +61,9 @@ export default Controller.extend(
|
|||
sources(topic) {
|
||||
const privateContext =
|
||||
this.siteSettings.login_required ||
|
||||
(topic && topic.isPrivateMessage) ||
|
||||
(topic && topic.invisible) ||
|
||||
topic.category.read_restricted;
|
||||
topic?.isPrivateMessage ||
|
||||
topic?.invisible ||
|
||||
topic?.category?.read_restricted;
|
||||
|
||||
return Sharing.activeSources(
|
||||
this.siteSettings.share_links,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
}
|
||||
input,
|
||||
.select-kit {
|
||||
cursor: auto;
|
||||
width: 100%;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user