From 1712081f0b478987df0302a3282c239b4f6e377b Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 20 Apr 2019 09:12:30 -0700 Subject: [PATCH] fix: fix profile clicks from compose dialog (#1160) * fix: don't allow profile clicks from compose dialog fixes #1159 * make the links work correctly in the modal * fix tests --- .../_components/compose/ComposeAuthor.html | 33 ++++++++++++------- .../_components/compose/ComposeBox.html | 5 +-- .../dialog/components/ComposeDialog.html | 2 +- tests/spec/029-back-button-modal.js | 21 ++++++++++-- tests/spec/118-display-name-custom-emoji.js | 26 ++++++--------- tests/utils.js | 4 +++ 6 files changed, 59 insertions(+), 32 deletions(-) diff --git a/src/routes/_components/compose/ComposeAuthor.html b/src/routes/_components/compose/ComposeAuthor.html index ccd519bf..d9b0c277 100644 --- a/src/routes/_components/compose/ComposeAuthor.html +++ b/src/routes/_components/compose/ComposeAuthor.html @@ -1,16 +1,20 @@ + aria-hidden={true} + on:click="onClick(event)" +> + rel="prefetch" + on:click="onClick(event)" +> + {'@' + verifyCredentials.acct} @@ -64,8 +68,9 @@ import Avatar from '../Avatar.html' import { store } from '../../_store/store' import AccountDisplayName from '../profile/AccountDisplayName.html' - import { removeEmoji } from '../../_utils/removeEmoji' import { ONE_TRANSPARENT_PIXEL } from '../../_static/media' + import { emit } from '../../_utils/eventBus' + import { goto } from '../../../../__sapper__/client' export default { components: { @@ -86,14 +91,20 @@ } }, id: ({ verifyCredentials }) => (verifyCredentials && verifyCredentials.id), - href: ({ id }) => (id ? `/accounts/${id}` : '#'), - emojis: ({ verifyCredentials }) => (verifyCredentials.emojis || []), - displayName: ({ verifyCredentials }) => verifyCredentials.display_name || verifyCredentials.username || '', - accessibleName: ({ displayName, emojis, $omitEmojiInDisplayNames }) => { - if ($omitEmojiInDisplayNames) { - return removeEmoji(displayName, emojis) || displayName + href: ({ id }) => (id ? `/accounts/${id}` : '#') + }, + methods: { + onClick (e) { + let { realm, dialogId, href } = this.get() + if (realm === 'dialog') { + e.preventDefault() + e.stopPropagation() + // in dialog mode, we have to close the dialog and then navigate to the profile + emit('closeDialog', dialogId) + setTimeout(() => { // setTimeout to work around dialog navigation issues + goto(href) + }) } - return displayName } } } diff --git a/src/routes/_components/compose/ComposeBox.html b/src/routes/_components/compose/ComposeBox.html index 20487c0e..ef775a50 100644 --- a/src/routes/_components/compose/ComposeBox.html +++ b/src/routes/_components/compose/ComposeBox.html @@ -3,7 +3,7 @@ {/if}
- + {#if contentWarningShown}
@@ -120,7 +120,8 @@ isReply: false, autoFocus: false, hideBottomBorder: false, - hidden: false + hidden: false, + dialogId: void 0 }), store: () => store, computed: { diff --git a/src/routes/_components/dialog/components/ComposeDialog.html b/src/routes/_components/dialog/components/ComposeDialog.html index 78415fc3..be98e51e 100644 --- a/src/routes/_components/dialog/components/ComposeDialog.html +++ b/src/routes/_components/dialog/components/ComposeDialog.html @@ -4,7 +4,7 @@ {title} background="var(--main-bg)" > - +