From 4954c2a326a5fd7493d97f35263f37cfff91af19 Mon Sep 17 00:00:00 2001 From: TMuthu Date: Fri, 29 Sep 2023 22:35:40 +0530 Subject: [PATCH] fixed disabled tab issue --- .../src/components/Tabs/Tabs.svelte | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/svelteui-core/src/components/Tabs/Tabs.svelte b/packages/svelteui-core/src/components/Tabs/Tabs.svelte index a1b4cd39..19bf4c88 100644 --- a/packages/svelteui-core/src/components/Tabs/Tabs.svelte +++ b/packages/svelteui-core/src/components/Tabs/Tabs.svelte @@ -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 });