Skip to content

Commit

Permalink
fix(NcRichContenteditable): remove doubling proxied event handlers
Browse files Browse the repository at this point in the history
Co-authored-by: Pytal <24800714+Pytal@users.noreply.github.com>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
  • Loading branch information
ShGKme and Pytal committed Jun 30, 2023
1 parent 3d77f33 commit 9bdba1b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/components/NcRichContenteditable/NcRichContenteditable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ export default {
aria-multiline="true"
class="rich-contenteditable__input"
role="textbox"
v-on="listeners"
@input="onInput"
v-on="$listeners"
@keydown.delete="onDelete"
@keydown.enter.exact="onEnter"
@keydown.ctrl.enter.exact.stop.prevent="onCtrlEnter"
Expand Down Expand Up @@ -423,6 +423,23 @@ export default {
canEdit() {
return this.contenteditable && !this.disabled
},

/**
* Proxied native event handlers without custom event handlers
*
* @return {Record<string, Function>}
*/
listeners() {
/**
* All component's event handlers are set as native event handlers with by v-on directive.
* The component also raised custom events manually by $emit for corresponding events.
* As a result, it triggers handlers twice.
* The v-on="listeners" directive should only set proxied native events handler without custom events
*/
const listeners = { ...this.$listeners }
delete listeners.paste
return listeners
},
},

watch: {
Expand Down

0 comments on commit 9bdba1b

Please sign in to comment.