diff --git a/app/assets/javascripts/discourse/app/controllers/share-topic.js b/app/assets/javascripts/discourse/app/controllers/share-topic.js index 638a704c31..31599e3b14 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.scss index 561e7b4181..fe3087f6cc 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; }