FIX: correctly filters input with pre-filled value (#20154)
Before this fix we would fill the input but that wouldn't trigger the actual filtering.
This commit is contained in:
parent
e66fa8c48b
commit
24f026c895
|
@ -14,11 +14,14 @@
|
|||
<DcFilterInput
|
||||
@class="chat-emoji-picker__filter"
|
||||
@value={{this.chatEmojiPickerManager.initialFilter}}
|
||||
@filterAction={{this.didInputFilter}}
|
||||
@filterAction={{action this.didInputFilter value="target.value"}}
|
||||
@icons={{hash left="search"}}
|
||||
placeholder={{i18n "chat.emoji_picker.search_placeholder"}}
|
||||
autofocus={{true}}
|
||||
{{did-insert this.focusFilter}}
|
||||
{{did-insert
|
||||
(fn this.didInputFilter this.chatEmojiPickerManager.initialFilter)
|
||||
}}
|
||||
>
|
||||
<div
|
||||
class="chat-emoji-picker__fitzpatrick-scale"
|
||||
|
|
|
@ -195,18 +195,13 @@ export default class ChatEmojiPicker extends Component {
|
|||
}
|
||||
|
||||
@action
|
||||
didInputFilter(event) {
|
||||
if (!event.target.value.length) {
|
||||
didInputFilter(value) {
|
||||
if (!value?.length) {
|
||||
this.filteredEmojis = null;
|
||||
return;
|
||||
}
|
||||
|
||||
discourseDebounce(
|
||||
this,
|
||||
this.debouncedDidInputFilter,
|
||||
event.target.value,
|
||||
INPUT_DELAY
|
||||
);
|
||||
discourseDebounce(this, this.debouncedDidInputFilter, value, INPUT_DELAY);
|
||||
}
|
||||
|
||||
@action
|
||||
|
|
|
@ -108,6 +108,16 @@ RSpec.describe "Chat composer", type: :system, js: true do
|
|||
|
||||
expect(find(".chat-emoji-picker .dc-filter-input").value).to eq("gri")
|
||||
end
|
||||
|
||||
it "filters with the prefilled input" do
|
||||
chat.visit_channel(channel_1)
|
||||
find(".chat-composer-input").fill_in(with: ":fr")
|
||||
|
||||
click_link(I18n.t("js.composer.more_emoji"))
|
||||
|
||||
expect(page).to have_selector(".chat-emoji-picker [data-emoji='fr']")
|
||||
expect(page).to have_no_selector(".chat-emoji-picker [data-emoji='grinning']")
|
||||
end
|
||||
end
|
||||
|
||||
context "when typing on keyboard" do
|
||||
|
|
Loading…
Reference in New Issue