Skip to content

Commit cf939ce

Browse files
authored
Merge branch 'master' into next
2 parents 05e7078 + 635b512 commit cf939ce

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed

src/structured-list/list-row.component.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ import { ListColumn } from "./list-column.component";
3838
<ng-container *ngIf="selection">
3939
<input
4040
#input
41-
tabindex="-1"
4241
class="cds--structured-list-input cds--visually-hidden"
4342
type="radio"
4443
[value]="value"
4544
[name]="name"
4645
[title]="label"
46+
(focus)="handleFocus(true)"
47+
(blur)="handleFocus(false)"
4748
(change)="onChange($event)"
4849
[checked]="selected"/>
4950
<div class="cds--structured-list-td">
@@ -80,7 +81,6 @@ export class ListRow implements AfterContentInit {
8081
name = "list";
8182

8283
@HostBinding("class.cds--structured-list-row") wrapper = true;
83-
@HostBinding("attr.tabindex") tabindex = this.selection ? "0" : null;
8484
@HostBinding("attr.role") role = "row";
8585

8686
@ContentChildren(ListColumn) columns: QueryList<ListColumn>;
@@ -102,18 +102,17 @@ export class ListRow implements AfterContentInit {
102102
this.input.nativeElement.click();
103103
}
104104
}
105-
106-
@HostListener("focus")
107-
onfocus() {
108-
this.isFocused = true;
109-
}
110-
111-
@HostListener("blur")
112-
onblur() {
113-
this.isFocused = false;
114-
}
115-
105+
116106
onChange(event) {
117107
this.change.emit(event);
118108
}
109+
110+
handleFocus(isFocused) {
111+
if (this.selection) {
112+
this.isFocused = isFocused;
113+
if (this.isFocused) {
114+
this.input.nativeElement.click();
115+
}
116+
}
117+
}
119118
}

src/structured-list/structured-list.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ export class StructuredList implements AfterContentInit, ControlValueAccessor {
152152
this.rows.forEach(row => {
153153
setSelection(row);
154154
row.name = this.name;
155-
row.tabindex = this.selection ? "0" : null;
156155
row.change.subscribe(() => {
157156
this.selected.emit({
158157
value: row.value,
159158
selected: row.selected,
160159
name: this.name
161160
});
162161
this.onChange(row.value);
162+
this.writeValue(row.value);
163163
});
164164
});
165165
this.updateChildren();

src/structured-list/structured-list.stories.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,28 @@ const SelectionTemplate = (args) => ({
105105
Pellentesque vulputate nisl a porttitor interdum.
106106
</cds-list-column>
107107
</cds-list-row>
108+
<cds-list-row value="row3">
109+
<cds-list-column>Row 3</cds-list-column>
110+
<cds-list-column nowrap="true">Row Three</cds-list-column>
111+
<cds-list-column>
112+
Lorem ipsum dolor sit amet,
113+
consectetur adipiscing elit. Nunc dui magna,
114+
finibus id tortor sed, aliquet bibendum augue.
115+
Aenean posuere sem vel euismod dignissim. Nulla ut cursus dolor.
116+
Pellentesque vulputate nisl a porttitor interdum.
117+
</cds-list-column>
118+
</cds-list-row>
119+
<cds-list-row value="row4">
120+
<cds-list-column>Row 4</cds-list-column>
121+
<cds-list-column nowrap="true">Row Four</cds-list-column>
122+
<cds-list-column>
123+
Lorem ipsum dolor sit amet,
124+
consectetur adipiscing elit. Nunc dui magna,
125+
finibus id tortor sed, aliquet bibendum augue.
126+
Aenean posuere sem vel euismod dignissim. Nulla ut cursus dolor.
127+
Pellentesque vulputate nisl a porttitor interdum.
128+
</cds-list-column>
129+
</cds-list-row>
108130
</cds-structured-list>
109131
<p>{{valueSelected}}</p>
110132
`

0 commit comments

Comments
 (0)