Commit 5f34566
authored
(fix) Compute content switcher selectedIndex from visible answers (#699)
selectedIndex was computed from the unfiltered answers array but the
rendered Switch children were filtered to exclude hidden answers. When
hidden answers preceded the selected answer, the index would be too
high, causing Carbon to highlight the wrong option. Compute both the
index and the rendered list from the same filtered visibleAnswers array.1 parent 584f7fd commit 5f34566
File tree
1 file changed
+15
-12
lines changed- src/components/inputs/content-switcher
1 file changed
+15
-12
lines changedLines changed: 15 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
24 | 29 | | |
25 | | - | |
26 | | - | |
| 30 | + | |
| 31 | + | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
| |||
59 | 64 | | |
60 | 65 | | |
61 | 66 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
| |||
0 commit comments