Skip to content

Commit

Permalink
fix(textarea): inherit tabindex to inner textarea (#26945)
Browse files Browse the repository at this point in the history
resolves #26944
  • Loading branch information
liamdebeasi authored Mar 13, 2023
1 parent 389595d commit 2c68d01
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
14 changes: 14 additions & 0 deletions core/src/components/input/test/input.spec.ts
Original file line number Diff line number Diff line change
@@ -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: '<ion-input title="my title" tabindex="-1" data-form-type="password"></ion-input>',
});

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');
});
14 changes: 14 additions & 0 deletions core/src/components/textarea/test/textarea.spec.ts
Original file line number Diff line number Diff line change
@@ -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: '<ion-textarea title="my title" tabindex="-1" data-form-type="password"></ion-textarea>',
});

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');
});
2 changes: 1 addition & 1 deletion core/src/components/textarea/textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
};
}

Expand Down

0 comments on commit 2c68d01

Please sign in to comment.