|
84 | 84 | },
|
85 | 85 | value: {
|
86 | 86 | type: Number,
|
87 |
| - default: 0 |
| 87 | + default: null |
88 | 88 | },
|
89 | 89 | pills: {
|
90 | 90 | type: Boolean,
|
|
183 | 183 | return;
|
184 | 184 | }
|
185 | 185 |
|
186 |
| - // Deactivate any previous active tab(s) |
| 186 | + // Activate current tab, and deactivte any old tabs |
187 | 187 | this.tabs.forEach( t => {
|
188 |
| - if (t !== tab && t.localActive) { |
189 |
| - this.$set(t, 'localActive', false); |
| 188 | + if (t === tab) { |
| 189 | + // Set new tab as active |
| 190 | + this.$set(t, 'localActive', true); |
| 191 | + } else { |
| 192 | + // Ensure non current tabs are not active |
| 193 | + this.$set(tab, 'localActive', false); |
190 | 194 | }
|
191 | 195 | });
|
192 | 196 |
|
193 |
| - // Set new tab as active |
194 |
| - this.$set(tab, 'localActive', true); |
195 |
| -
|
196 | 197 | // Update currentTab
|
197 | 198 | this.currentTab = index + offset;
|
198 | 199 | },
|
|
218 | 219 | let tabIndex = this.currentTab;
|
219 | 220 |
|
220 | 221 | if (tabIndex === null || tabIndex === undefined) {
|
221 |
| - // Find last active tab in current tabs |
| 222 | + // Make null for easier testing further on |
| 223 | + tabIndex = null; |
| 224 | + } |
| 225 | +
|
| 226 | + if (tabIndex === null) { |
| 227 | + // Find last active non-dsabled tab in current tabs |
| 228 | + this.tabs.forEach((tab, index) => { |
| 229 | + if (tab.active && !tab.disabled) { |
| 230 | + tabIndex = index; |
| 231 | + } |
| 232 | + }); |
| 233 | + } |
| 234 | +
|
| 235 | + if (tabIndex === null) { |
| 236 | + // Find first non-disabled tab in current tabs |
222 | 237 | this.tabs.forEach((tab, index) => {
|
223 |
| - if (tab.active) { |
| 238 | + if (!tab.disabled && tabIndex === null) { |
224 | 239 | tabIndex = index;
|
225 | 240 | }
|
226 | 241 | });
|
227 | 242 | }
|
228 | 243 |
|
229 | 244 | // Workaround to fix problem when currentTab is removed
|
230 | 245 | let offset = 0;
|
231 |
| - if (tabIndex > this.tabs.length - 1) { |
| 246 | + if (tabIndex >= this.tabs.length) { |
232 | 247 | offset = -1;
|
233 | 248 | }
|
234 | 249 |
|
|
0 commit comments