diff --git a/src/routes/_components/dialog/components/CopyDialog.html b/src/routes/_components/dialog/components/CopyDialog.html index 768f041..36991dd 100644 --- a/src/routes/_components/dialog/components/CopyDialog.html +++ b/src/routes/_components/dialog/components/CopyDialog.html @@ -4,6 +4,7 @@ {title} shrinkWidthToFit={true} background="var(--main-bg)" + on:show="onShow()" >
{ - input.focus() - input.setSelectionRange(0, text.length) - }) }, methods: { show, @@ -63,6 +57,15 @@ copyFromInput(input) toast.say('Copied to clipboard') this.close() + }, + onShow () { + let { text } = this.get() + let { input } = this.refs + // double raf is to work around a11y-dialog trying to set the input + doubleRAF(() => { + input.focus() + input.setSelectionRange(0, text.length) + }) } }, data: () => ({ diff --git a/src/routes/_components/dialog/components/EmojiDialog.html b/src/routes/_components/dialog/components/EmojiDialog.html index 3a49d8a..4ae9bd3 100644 --- a/src/routes/_components/dialog/components/EmojiDialog.html +++ b/src/routes/_components/dialog/components/EmojiDialog.html @@ -4,6 +4,7 @@ {title} shrinkWidthToFit={true} background="var(--main-bg)" + on:show="onShow()" >
{#if loaded} @@ -104,7 +105,6 @@ define({ 'emoji-mart': Picker }) } this.set({ loaded: true }) - this.focusIfNecessary() } catch (error) { this.set({ error }) // should never happen, but you never know } @@ -168,6 +168,9 @@ insertEmoji(realm, emoji) this.close() }, + onShow () { + this.focusIfNecessary() + }, focusIfNecessary () { let { autoFocus } = this.get() if (!autoFocus) { diff --git a/src/routes/_components/dialog/components/MediaDialog.html b/src/routes/_components/dialog/components/MediaDialog.html index 7b84505..2cab9e8 100644 --- a/src/routes/_components/dialog/components/MediaDialog.html +++ b/src/routes/_components/dialog/components/MediaDialog.html @@ -4,6 +4,7 @@ background="var(--muted-modal-bg)" muted="true" className="media-modal-dialog" + on:show="onShow()" >
    @@ -199,24 +200,12 @@ import debounce from 'lodash-es/debounce' import times from 'lodash-es/times' import { smoothScroll, hasNativeSmoothScroll } from '../../../_utils/smoothScroll' - import { doubleRAF } from '../../../_utils/doubleRAF' import { store } from '../../../_store/store' export default { oncreate () { onCreateDialog.call(this) - this.onScroll = debounce(this.onScroll.bind(this), 50, { leading: false, trailing: true }) - - let { scrolledItem } = this.get() - if (scrolledItem) { - doubleRAF(() => { - this.scrollToItem(scrolledItem, false) - this.setupScroll() - }) - } else { - this.setupScroll() - } }, ondestroy () { this.teardownScroll() @@ -287,6 +276,17 @@ this.scrollToItem(scrolledItem - 1, true) } }, + onShow () { + let { scrolledItem } = this.get() + if (scrolledItem) { + requestAnimationFrame(() => { + this.scrollToItem(scrolledItem, false) + this.setupScroll() + }) + } else { + this.setupScroll() + } + }, scrollToItem (scrolledItem, smooth) { this.set({ scrolledItem: scrolledItem }) let { length } = this.get() @@ -302,6 +302,7 @@ smoothScroll(scroller, scrollLeft, true) } } else { + console.log('setting scrollLeft', scrollLeft) scroller.scrollLeft = scrollLeft } }, diff --git a/src/routes/_components/dialog/components/ModalDialog.html b/src/routes/_components/dialog/components/ModalDialog.html index b312afd..5ef0233 100644 --- a/src/routes/_components/dialog/components/ModalDialog.html +++ b/src/routes/_components/dialog/components/ModalDialog.html @@ -227,6 +227,7 @@ document.body.classList.toggle('modal-open', true) this._a11yDialog.show() this.set({ fadedIn: true }) + this.fire('show') }) }) }, diff --git a/src/routes/_components/dialog/components/ReportDialog.html b/src/routes/_components/dialog/components/ReportDialog.html index 92fd96c..e526f8e 100644 --- a/src/routes/_components/dialog/components/ReportDialog.html +++ b/src/routes/_components/dialog/components/ReportDialog.html @@ -147,7 +147,7 @@ export default { async oncreate () { - onCreateDialog.apply(this) + onCreateDialog.call(this) let { account, status, reportMap } = this.get() if (status) { reportMap[status.id] = true