A platform for community discussion. Free, open, simple.
FEATURE: Automatically select share URL (#16025)
Bianca Nenciue0b683f98e57
diff --git a/app/assets/javascripts/discourse/app/controllers/share-topic.js b/app/assets/javascripts/discourse/app/controllers/share-topic.jsindex 638a704c319..31599e3b14f 100644--- a/app/assets/javascripts/discourse/app/controllers/share-topic.js+++ b/app/assets/javascripts/discourse/app/controllers/share-topic.js@@ -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,diff --git a/app/assets/stylesheets/common/base/share_link.scss b/app/assets/stylesheets/common/base/share_link.scssindex 561e7b4181e..fe3087f6cc5 100644--- a/app/assets/stylesheets/common/base/share_link.scss+++ b/app/assets/stylesheets/common/base/share_link.scss@@ -8,6 +8,7 @@}input,.select-kit {+ cursor: auto;width: 100%;margin-bottom: 0;}