fix multiple compose autosuggest dropdowns (#188)
* fix multiple compose autosuggest dropdowns Fixes #170 * fix failing test * remove console.log
This commit is contained in:
parent
e847e54f96
commit
581a0fcd00
|
@ -134,6 +134,7 @@
|
||||||
computed: {
|
computed: {
|
||||||
composeSelectionStart: ($composeSelectionStart) => $composeSelectionStart,
|
composeSelectionStart: ($composeSelectionStart) => $composeSelectionStart,
|
||||||
composeFocused: ($composeFocused) => $composeFocused,
|
composeFocused: ($composeFocused) => $composeFocused,
|
||||||
|
thisComposeFocused: (composeFocusedDeferred, realm) => composeFocusedDeferred === realm,
|
||||||
searchResults: ($composeAutosuggestionSearchResults) => $composeAutosuggestionSearchResults || [],
|
searchResults: ($composeAutosuggestionSearchResults) => $composeAutosuggestionSearchResults || [],
|
||||||
type: ($composeAutosuggestionType) => $composeAutosuggestionType || 'account',
|
type: ($composeAutosuggestionType) => $composeAutosuggestionType || 'account',
|
||||||
selected: ($composeAutosuggestionSelected) => $composeAutosuggestionSelected || 0,
|
selected: ($composeAutosuggestionSelected) => $composeAutosuggestionSelected || 0,
|
||||||
|
@ -147,8 +148,8 @@
|
||||||
let match = textUpToCursor.match(ACCOUNT_SEARCH_REGEX) || textUpToCursor.match(EMOJI_SEARCH_REGEX)
|
let match = textUpToCursor.match(ACCOUNT_SEARCH_REGEX) || textUpToCursor.match(EMOJI_SEARCH_REGEX)
|
||||||
return match && match[1]
|
return match && match[1]
|
||||||
},
|
},
|
||||||
shown: (composeFocusedDeferred, searchText, searchResults) => {
|
shown: (thisComposeFocused, searchText, searchResults) => {
|
||||||
return !!(composeFocusedDeferred &&
|
return !!(thisComposeFocused &&
|
||||||
searchText &&
|
searchText &&
|
||||||
searchResults.length)
|
searchResults.length)
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,10 +93,11 @@
|
||||||
stop('autosize.destroy()')
|
stop('autosize.destroy()')
|
||||||
},
|
},
|
||||||
onBlur () {
|
onBlur () {
|
||||||
this.store.set({composeFocused: false})
|
this.store.set({composeFocused: null})
|
||||||
},
|
},
|
||||||
onFocus () {
|
onFocus () {
|
||||||
this.store.set({composeFocused: true})
|
let { realm } = this.get()
|
||||||
|
this.store.set({composeFocused: realm})
|
||||||
},
|
},
|
||||||
onSelectionChange (selectionStart) {
|
onSelectionChange (selectionStart) {
|
||||||
this.store.set({composeSelectionStart: selectionStart})
|
this.store.set({composeSelectionStart: selectionStart})
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import {
|
import {
|
||||||
composeInput, getNthAutosuggestionResult
|
composeInput, getNthAutosuggestionResult, getNthComposeReplyInput, getNthReplyButton, getNthStatus
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
|
import { Selector as $ } from 'testcafe'
|
||||||
import { foobarRole } from '../roles'
|
import { foobarRole } from '../roles'
|
||||||
|
|
||||||
fixture`018-compose-autosuggest.js`
|
fixture`018-compose-autosuggest.js`
|
||||||
|
@ -80,3 +81,15 @@ test('autosuggest handles works with regular emoji - clicking', async t => {
|
||||||
.click(getNthAutosuggestionResult(1))
|
.click(getNthAutosuggestionResult(1))
|
||||||
.expect(composeInput.value).eql('\ud83c\udf4d @quux ')
|
.expect(composeInput.value).eql('\ud83c\udf4d @quux ')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('autosuggest only shows for one input', async t => {
|
||||||
|
await t.useRole(foobarRole)
|
||||||
|
.hover(composeInput)
|
||||||
|
.typeText(composeInput, '@quu')
|
||||||
|
.hover(getNthStatus(0))
|
||||||
|
.click(getNthReplyButton(0))
|
||||||
|
.selectText(getNthComposeReplyInput(0))
|
||||||
|
.pressKey('delete')
|
||||||
|
.typeText(getNthComposeReplyInput(0), 'uu')
|
||||||
|
.expect($('.compose-autosuggest.shown').exists).notOk()
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue