Skip to content

Commit 1a62eb9

Browse files
committed
Merge branch 'Tab-click_cancellable_using_event.defaultPrevented' of https://github.com/TylerRick/svelte-material-ui into TylerRick-Tab-click_cancellable_using_event.defaultPrevented
2 parents 2273e28 + 4f0c60a commit 1a62eb9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/tab/src/Tab.svelte

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
aria-selected={active ? 'true' : 'false'}
3232
tabindex={active || forceAccessible ? '0' : '-1'}
3333
{href}
34-
on:click={() => instance && instance.handleClick()}
34+
on:click={handleClick}
3535
{...internalAttrs}
3636
{...exclude($$restProps, ['content$', 'tabIndicator$'])}
3737
>
@@ -84,7 +84,7 @@
8484
import type { TabIndicatorComponentDev } from '@smui/tab-indicator';
8585
import TabIndicator from '@smui/tab-indicator';
8686
87-
import type { SMUITabAccessor } from './Tab.types.js';
87+
import type { SMUITabAccessor } from './Tab.types';
8888
8989
const forwardEvents = forwardEventsBuilder(get_current_component());
9090
@@ -182,6 +182,12 @@
182182
};
183183
});
184184
185+
function handleClick(event: PointerEvent) {
186+
if (!event.defaultPrevented) {
187+
instance?.handleClick();
188+
}
189+
}
190+
185191
function hasClass(className: string) {
186192
return className in internalClasses
187193
? internalClasses[className]

0 commit comments

Comments
 (0)