From a82c44c21ff6b3bfaf91bf6302e4b9618e190418 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Thu, 12 Apr 2018 21:18:14 -0700 Subject: [PATCH] Replying returns focus to reply button (#98) Fixes #42 --- routes/_actions/compose.js | 4 ++-- routes/_components/compose/ComposeBox.html | 4 +++- routes/_components/status/Status.html | 2 +- .../_components/status/StatusComposeBox.html | 1 + routes/_components/status/StatusToolbar.html | 15 ++++++++++++- tests/spec/111-focus.js | 21 +++++++++++++++++++ 6 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 tests/spec/111-focus.js diff --git a/routes/_actions/compose.js b/routes/_actions/compose.js index f221178e..a5b68a1b 100644 --- a/routes/_actions/compose.js +++ b/routes/_actions/compose.js @@ -22,7 +22,7 @@ export async function insertHandleForReply (statusId) { export async function postStatus (realm, text, inReplyToId, mediaIds, sensitive, spoilerText, visibility, - mediaDescriptions = []) { + mediaDescriptions = [], inReplyToUuid) { let instanceName = store.get('currentInstance') let accessToken = store.get('accessToken') let online = store.get('online') @@ -43,7 +43,7 @@ export async function postStatus (realm, text, inReplyToId, mediaIds, inReplyToId, mediaIds, sensitive, spoilerText, visibility) addStatusOrNotification(instanceName, 'home', status) store.clearComposeData(realm) - emit('postedStatus', realm) + emit('postedStatus', realm, inReplyToUuid) } catch (e) { console.error(e) toast.say('Unable to post status: ' + (e.message || '')) diff --git a/routes/_components/compose/ComposeBox.html b/routes/_components/compose/ComposeBox.html index f1c1f0dc..b341e006 100644 --- a/routes/_components/compose/ComposeBox.html +++ b/routes/_components/compose/ComposeBox.html @@ -215,6 +215,7 @@ let inReplyTo = (realm === 'home' || realm === 'dialog') ? null : realm let overLimit = this.get('overLimit') let mediaDescriptions = this.get('mediaDescriptions') + let inReplyToUuid = this.get('inReplyToUuid') if (!text || overLimit) { return // do nothing if invalid @@ -222,7 +223,8 @@ /* no await */ postStatus(realm, text, inReplyTo, mediaIds, - sensitive, contentWarning, postPrivacyKey, mediaDescriptions) + sensitive, contentWarning, postPrivacyKey, + mediaDescriptions, inReplyToUuid) }, setupStickyObserver() { this.__stickyObserver = new IntersectionObserver(entries => { diff --git a/routes/_components/status/Status.html b/routes/_components/status/Status.html index c0f3e16e..af79266c 100644 --- a/routes/_components/status/Status.html +++ b/routes/_components/status/Status.html @@ -5,7 +5,7 @@ aria-posinset="{{index}}" aria-setsize="{{length}}" aria-label="{{ariaLabel}}" - on:recalculateHeight > + on:recalculateHeight> {{#if showHeader}} diff --git a/routes/_components/status/StatusComposeBox.html b/routes/_components/status/StatusComposeBox.html index f147d85d..efa40e92 100644 --- a/routes/_components/status/StatusComposeBox.html +++ b/routes/_components/status/StatusComposeBox.html @@ -6,6 +6,7 @@ isReply="true" replyVisibility="{{visibility}}" replySpoiler="{{spoilerText}}" + inReplyToUuid="{{uuid}}" />