Skip to content

Commit

Permalink
fix: resolve attributes function not handling states correctly (#2064)
Browse files Browse the repository at this point in the history
* fix: resolve attributes function not handling states correctly
  • Loading branch information
MarioCastigliano authored Oct 11, 2023
1 parent 1a29131 commit dc981b5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
7 changes: 3 additions & 4 deletions src/components/sbb-button/sbb-button.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('sbb-button', () => {
disabled
aria-disabled="true"
name="name"
value="value"
value="value"
form="formid"
role="button"
dir="ltr"
Expand Down Expand Up @@ -165,15 +165,14 @@ describe('sbb-button', () => {
expect(root).to.have.attribute('data-icon-only');
});

// TODO-Migr: enable this test after the FormField migration
it.skip('should render form field button variant when inside of a form field', async () => {
it('should render form field button variant when inside of a form field', async () => {
const root = await fixture(
html` <sbb-form-field>
<input />
<sbb-button slot="suffix" icon-name="cross-small" />
</sbb-form-field>`,
);

expect(root).to.have.attribute('data-icon-small');
expect(root.querySelector('sbb-button')).to.have.attribute('data-icon-small');
});
});
2 changes: 0 additions & 2 deletions src/components/sbb-link/sbb-link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe('sbb-link', () => {
tabindex="0"
dir="ltr"
>
Travelcards &amp; tickets.
</sbb-link>
`);
Expand Down Expand Up @@ -73,7 +72,6 @@ describe('sbb-link', () => {
aria-disabled="true"
dir="ltr"
>
<sbb-icon name="chevron-small-right-small" slot="icon" role="img" aria-hidden="true" data-namespace="default"></sbb-icon>
Travelcards &amp; tickets.
</sbb-link>
Expand Down
4 changes: 2 additions & 2 deletions src/components/sbb-menu-action/sbb-menu-action.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('sbb-menu-action', () => {

expect(root).dom.to.be.equal(
`
<sbb-menu-action form="formid" name="name" type="submit" role="button" tabindex="0" dir="ltr">
<sbb-menu-action form="formid" name="name" type="submit" role="button" tabindex="0" dir="ltr">
<span>Action</span>
</sbb-menu-action>
`,
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('sbb-menu-action', () => {

expect(root).dom.to.be.equal(
`
<sbb-menu-action amount="123456" icon-name="menu-small" href="https://github.com/lyne-design-system/lyne-components" target="_blank" role="link" tabindex="0" dir="ltr">
<sbb-menu-action amount="123456" icon-name="menu-small" href="https://github.com/lyne-design-system/lyne-components" target="_blank" role="link" tabindex="0" dir="ltr">
<span>Action</span>
</sbb-menu-action>
`,
Expand Down
1 change: 0 additions & 1 deletion src/components/sbb-toggle-check/sbb-toggle-check.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ describe('sbb-toggle-check', () => {
expect(root).dom.to.be.equal(
`
<sbb-toggle-check size="s" aria-checked="true" aria-disabled="false" aria-required="false" checked label-position="after" role="checkbox" tabindex="0">
</sbb-toggle-check>
`,
);
Expand Down
4 changes: 3 additions & 1 deletion src/global/interfaces/link-button-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ function getLinkAttributeList(linkProperties: LinkProperties): Record<string, st
function hostProperties(role: string, disabled: boolean): Record<string, string> {
return Object.assign(
{ role, dir: getDocumentWritingMode() },
disabled ? { 'aria-disabled': 'true' } : { tabIndex: '0' },
disabled
? { 'aria-disabled': 'true', tabIndex: null }
: { 'aria-disabled': null, tabIndex: '0' },
);
}

Expand Down

0 comments on commit dc981b5

Please sign in to comment.