Skip to content

Commit 50e0b02

Browse files
committed
fix(textarea): emit ion-textarea instead of native textarea with click event
1 parent 102ed94 commit 50e0b02

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core/src/components/textarea/textarea.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Element,
66
Event,
77
Host,
8+
Listen,
89
Method,
910
Prop,
1011
State,
@@ -314,6 +315,19 @@ export class Textarea implements ComponentInterface {
314315
*/
315316
@Event() ionFocus!: EventEmitter<FocusEvent>;
316317

318+
/**
319+
* This is prevents the native input from emitting the click event.
320+
* Instead, the click event from the ion-textarea is emitted.
321+
*/
322+
@Listen('click', { capture: true })
323+
onClickCapture(ev: Event) {
324+
const nativeInput = this.nativeInput;
325+
if (nativeInput && ev.target === nativeInput) {
326+
ev.stopPropagation();
327+
this.el.click();
328+
}
329+
}
330+
317331
connectedCallback() {
318332
const { el } = this;
319333
this.slotMutationController = createSlotMutationController(el, ['label', 'start', 'end'], () => forceUpdate(this));

0 commit comments

Comments
 (0)