mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Introduce a helper for handling events (#25433)
Instead of
```hbs
{{on "input" (action this.foo value="target.value")}}
{{on "input" (action (mut this.bar) value="target.value")}}
```
you can use:
```hbs
{{on "input" (with-event-value this.foo)}}
{{on "input" (with-event-value (fn (mut this.bar)))}}
```
or in gjs:
```gjs
import { fn } from "@ember/helper";
import { on } from "@ember/modifier";
import withEventValue from "discourse/helpers/with-event-value";
…
{{on "input" (withEventValue (fn (mut this.bar)))}}
```
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
)
|
||||
}}
|
||||
@value={{this.chatEmojiPickerManager.picker.initialFilter}}
|
||||
@filterAction={{action this.didInputFilter value="target.value"}}
|
||||
@filterAction={{with-event-value this.didInputFilter}}
|
||||
@icons={{hash left="search"}}
|
||||
@containerClass="chat-emoji-picker__filter"
|
||||
autofocus={{true}}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
class="chat-modal-create-channel__input"
|
||||
@type="text"
|
||||
@value={{this.name}}
|
||||
{{on "input" (action this.onNameChange value="target.value")}}
|
||||
{{on "input" (with-event-value this.onNameChange)}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -14,10 +14,7 @@
|
||||
@max={{this.descriptionMaxLength}}
|
||||
>
|
||||
<textarea
|
||||
{{on
|
||||
"input"
|
||||
(action this.onChangeChatChannelDescription value="target.value")
|
||||
}}
|
||||
{{on "input" (with-event-value this.onChangeChatChannelDescription)}}
|
||||
class="chat-modal-edit-channel-description__description-input"
|
||||
placeholder={{i18n
|
||||
"chat.channel_edit_description_modal.input_placeholder"
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
<StyleguideExample @title="<CharCounter>">
|
||||
<CharCounter @max="50" @value={{@dummy.charCounterContent}}>
|
||||
<textarea
|
||||
{{on
|
||||
"input"
|
||||
(action (mut @dummy.charCounterContent) value="target.value")
|
||||
}}
|
||||
{{on "input" (with-event-value (fn (mut @dummy.charCounterContent)))}}
|
||||
class="styleguide--char-counter"
|
||||
></textarea>
|
||||
</CharCounter>
|
||||
|
||||
Reference in New Issue
Block a user