Skip to content

Commit

Permalink
fixed disabled tab issue
Browse files Browse the repository at this point in the history
  • Loading branch information
TMuthu committed Sep 29, 2023
1 parent 5d5837b commit 4954c2a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/svelteui-core/src/components/Tabs/Tabs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,27 @@
let _index = _active;
if (event.code === nextTabCode) {
if (_index + 1 >= tabs.length) return;
_index += 1;
let current = _index + 1;
let end = tabs.length - 1;
while (current <= end)
if (tabs[current] && tabs[current]['disabled']) current++;
else break;
if (current > end) return;
_index = current;
} else if (event.code === previousTabCode) {
if (_index - 1 < 0) return;
_index -= 1;
let current = _index - 1;
let end = 0;
while (current >= end)
if (tabs[current] && tabs[current]['disabled']) current--;
else break;
if (current < end) return;
_index = current;
}
event.preventDefault();
const selectedTab = Array.from(tabs)[_index];
if (selectedTab) selectedTab['focus']();
const selectedKey = selectedTab.getAttribute('data-key');
dispatch('change', { index: _index, key: selectedKey });
Expand Down

0 comments on commit 4954c2a

Please sign in to comment.