compose button is not disabled by default

This commit is contained in:
Nolan Lawson 2018-03-22 17:55:35 -07:00
parent ff9c21d00a
commit d40befacdb
3 changed files with 9 additions and 5 deletions

View file

@ -115,8 +115,12 @@
let sensitive = media.length && !!contentWarning let sensitive = media.length && !!contentWarning
let realm = this.get('realm') let realm = this.get('realm')
let mediaIds = media.map(_ => _.data.id) let mediaIds = media.map(_ => _.data.id)
let inReplyTo = realm === 'home' ? null : realm 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, /* no await */ postStatus(realm, text, inReplyTo, mediaIds,
sensitive, contentWarning, postPrivacyKey) sensitive, contentWarning, postPrivacyKey)

View file

@ -43,7 +43,7 @@
export default { export default {
store: () => store, store: () => store,
computed: { computed: {
disabled: ($postingStatus, overLimit, length) => $postingStatus || overLimit || length === 0 disabled: ($postingStatus, overLimit) => $postingStatus || overLimit
} }
} }
</script> </script>

View file

@ -14,7 +14,7 @@ test('shows compose limits', async t => {
await t.useRole(foobarRole) await t.useRole(foobarRole)
.hover(composeInput) .hover(composeInput)
.expect(composeLengthIndicator.innerText).eql('500') .expect(composeLengthIndicator.innerText).eql('500')
.expect(composeButton.getAttribute('disabled')).eql('') .expect(composeButton.hasAttribute('disabled')).notOk()
.typeText(composeInput, 'typing some text') .typeText(composeInput, 'typing some text')
.expect(composeLengthIndicator.innerText).eql('484') .expect(composeLengthIndicator.innerText).eql('484')
.expect(composeButton.hasAttribute('disabled')).notOk() .expect(composeButton.hasAttribute('disabled')).notOk()
@ -33,13 +33,13 @@ test('shows compose limits', async t => {
.pressKey('delete') .pressKey('delete')
.expect(composeInput.value).eql('') .expect(composeInput.value).eql('')
.expect(composeLengthIndicator.innerText).eql('500') .expect(composeLengthIndicator.innerText).eql('500')
.expect(composeButton.getAttribute('disabled')).eql('') .expect(composeButton.hasAttribute('disabled')).notOk()
}) })
test('shows compose limits for URLs/handles', async t => { test('shows compose limits for URLs/handles', async t => {
await t.useRole(foobarRole) await t.useRole(foobarRole)
.expect(composeLengthIndicator.innerText).eql('500') .expect(composeLengthIndicator.innerText).eql('500')
.expect(composeButton.getAttribute('disabled')).eql('') .expect(composeButton.hasAttribute('disabled')).notOk()
.typeText(composeInput, 'hello world ' + .typeText(composeInput, 'hello world ' +
'http://foo.bar.baz.whatever.example.com/hello ' + 'http://foo.bar.baz.whatever.example.com/hello ' +
'@reallylongnamethatstretchesonandon@foo.example.com', {paste: true}) '@reallylongnamethatstretchesonandon@foo.example.com', {paste: true})