From 2c68d01b898a2f879445b8b64014189afe1255d7 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 13 Mar 2023 10:12:37 -0400 Subject: [PATCH] fix(textarea): inherit tabindex to inner textarea (#26945) resolves #26944 --- core/src/components/input/test/input.spec.ts | 14 ++++++++++++++ core/src/components/textarea/test/textarea.spec.ts | 14 ++++++++++++++ core/src/components/textarea/textarea.tsx | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 core/src/components/input/test/input.spec.ts create mode 100644 core/src/components/textarea/test/textarea.spec.ts diff --git a/core/src/components/input/test/input.spec.ts b/core/src/components/input/test/input.spec.ts new file mode 100644 index 00000000000..f07d46c8f0e --- /dev/null +++ b/core/src/components/input/test/input.spec.ts @@ -0,0 +1,14 @@ +import { newSpecPage } from '@stencil/core/testing'; +import { Input } from '../input'; + +it('should inherit attributes', async () => { + const page = await newSpecPage({ + components: [Input], + html: '', + }); + + const nativeEl = page.body.querySelector('ion-input input'); + expect(nativeEl.getAttribute('title')).toBe('my title'); + expect(nativeEl.getAttribute('tabindex')).toBe('-1'); + expect(nativeEl.getAttribute('data-form-type')).toBe('password'); +}); diff --git a/core/src/components/textarea/test/textarea.spec.ts b/core/src/components/textarea/test/textarea.spec.ts new file mode 100644 index 00000000000..a3e8a7ec131 --- /dev/null +++ b/core/src/components/textarea/test/textarea.spec.ts @@ -0,0 +1,14 @@ +import { newSpecPage } from '@stencil/core/testing'; +import { Textarea } from '../textarea'; + +it('should inherit attributes', async () => { + const page = await newSpecPage({ + components: [Textarea], + html: '', + }); + + const nativeEl = page.body.querySelector('ion-textarea textarea'); + expect(nativeEl.getAttribute('title')).toBe('my title'); + expect(nativeEl.getAttribute('tabindex')).toBe('-1'); + expect(nativeEl.getAttribute('data-form-type')).toBe('password'); +}); diff --git a/core/src/components/textarea/textarea.tsx b/core/src/components/textarea/textarea.tsx index 1f4f2211413..56b50233bda 100644 --- a/core/src/components/textarea/textarea.tsx +++ b/core/src/components/textarea/textarea.tsx @@ -223,7 +223,7 @@ export class Textarea implements ComponentInterface { componentWillLoad() { this.inheritedAttributes = { ...inheritAriaAttributes(this.el), - ...inheritAttributes(this.el, ['data-form-type', 'title']), + ...inheritAttributes(this.el, ['data-form-type', 'title', 'tabindex']), }; }