From d40befacdb186838f971dee77005a8060f7e6e56 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Thu, 22 Mar 2018 17:55:35 -0700 Subject: [PATCH] compose button is not disabled by default --- routes/_components/compose/ComposeBox.html | 6 +++++- routes/_components/compose/ComposeButton.html | 2 +- tests/spec/012-compose.js | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/routes/_components/compose/ComposeBox.html b/routes/_components/compose/ComposeBox.html index d1261916..8135bb29 100644 --- a/routes/_components/compose/ComposeBox.html +++ b/routes/_components/compose/ComposeBox.html @@ -115,8 +115,12 @@ let sensitive = media.length && !!contentWarning let realm = this.get('realm') let mediaIds = media.map(_ => _.data.id) - let inReplyTo = realm === 'home' ? null : realm + let overLimit = this.get('overLimit') + + if (!text || overLimit) { + return // do nothing if invalid + } /* no await */ postStatus(realm, text, inReplyTo, mediaIds, sensitive, contentWarning, postPrivacyKey) diff --git a/routes/_components/compose/ComposeButton.html b/routes/_components/compose/ComposeButton.html index 58055ce0..c940b1f2 100644 --- a/routes/_components/compose/ComposeButton.html +++ b/routes/_components/compose/ComposeButton.html @@ -43,7 +43,7 @@ export default { store: () => store, computed: { - disabled: ($postingStatus, overLimit, length) => $postingStatus || overLimit || length === 0 + disabled: ($postingStatus, overLimit) => $postingStatus || overLimit } } \ No newline at end of file diff --git a/tests/spec/012-compose.js b/tests/spec/012-compose.js index 9de1c142..ae1b25ca 100644 --- a/tests/spec/012-compose.js +++ b/tests/spec/012-compose.js @@ -14,7 +14,7 @@ test('shows compose limits', async t => { await t.useRole(foobarRole) .hover(composeInput) .expect(composeLengthIndicator.innerText).eql('500') - .expect(composeButton.getAttribute('disabled')).eql('') + .expect(composeButton.hasAttribute('disabled')).notOk() .typeText(composeInput, 'typing some text') .expect(composeLengthIndicator.innerText).eql('484') .expect(composeButton.hasAttribute('disabled')).notOk() @@ -33,13 +33,13 @@ test('shows compose limits', async t => { .pressKey('delete') .expect(composeInput.value).eql('') .expect(composeLengthIndicator.innerText).eql('500') - .expect(composeButton.getAttribute('disabled')).eql('') + .expect(composeButton.hasAttribute('disabled')).notOk() }) test('shows compose limits for URLs/handles', async t => { await t.useRole(foobarRole) .expect(composeLengthIndicator.innerText).eql('500') - .expect(composeButton.getAttribute('disabled')).eql('') + .expect(composeButton.hasAttribute('disabled')).notOk() .typeText(composeInput, 'hello world ' + 'http://foo.bar.baz.whatever.example.com/hello ' + '@reallylongnamethatstretchesonandon@foo.example.com', {paste: true})