Skip to content

Commit 2653a8a

Browse files
authored
fix(toggle): added missing name property (#1800)
* refactor: added missing name property * docs: added docs for name attribute * test: fix testcase
1 parent da701f7 commit 2653a8a

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

e2e/cypress/e2e/03-0-action/db-toggle.cy.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ context('db-toggle', () => {
1313
.check()
1414
.should('be.checked');
1515
cy.get('db-toggle> input')
16-
.eq(2)
16+
.eq(3)
1717
.should('be.checked')
1818
.uncheck()
1919
.should('not.be.checked');
2020
});
2121

2222
it('Toggle should be disabled', function () {
23-
cy.get('db-toggle > input').eq(1).should('be.disabled');
24-
cy.get('db-toggle > input').eq(3).should('be.disabled');
23+
cy.get('db-toggle > input').eq(2).should('be.disabled');
24+
cy.get('db-toggle > input').eq(4).should('be.disabled');
2525
});
2626
// it('Datalist option should be correct', function () {
2727
// cy.get('db-input > datalist > option')

packages/db-ui-elements-stencil/src/components/db-toggle/db-toggle.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export class DbToggle {
1818
* Checked property
1919
*/
2020
@Prop({ reflect: true }) checked: boolean;
21+
/**
22+
* The name attribute specifies a name for the included input element.
23+
*/
24+
@Prop({ reflect: true }) name?: string;
2125

2226
private handleChange(event) {
2327
this.dbChange.emit(event);
@@ -38,6 +42,7 @@ export class DbToggle {
3842
disabled={this.disabled}
3943
checked={this.checked}
4044
id={this.htmlid}
45+
name={this.name}
4146
onChange={(event) => this.handleChange(event)}
4247
/>
4348
<label class="elm-label" htmlFor={this.htmlid}>

packages/db-ui-elements-stencil/src/components/db-toggle/stories/db-toggle.intro.stories.mdx

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import Readme from './../readme.md';
1111
<db-toggle></db-toggle>
1212
</Canvas>
1313

14+
<Canvas>
15+
<db-toggle name="unique-name">Toggle with a unique `name`-attribute</db-toggle>
16+
</Canvas>
17+
1418
<db-headline>The toggle component with text. </db-headline>
1519

1620
<Canvas>

0 commit comments

Comments
 (0)