Skip to content

Commit

Permalink
refactor: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki committed Feb 16, 2024
1 parent 3c062f8 commit 8ca868f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/side-nav/src/vaadin-side-nav.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface SideNavCustomEventMap {

export type SideNavEventMap = HTMLElementEventMap & SideNavCustomEventMap;

export type OnNavigateProps = {
export type NavigateEvent = {
path: SideNavItem['path'];
target: SideNavItem['target'];
current: SideNavItem['current'];
Expand Down Expand Up @@ -99,7 +99,7 @@ declare class SideNav extends SideNavChildrenMixin(FocusMixin(ElementMixin(Thema
* When a side nav item link is clicked, this function is called and the default click action is cancelled.
* This delegates the responsibility of navigation to the function's logic.
*
* The click event is not cancelled in the following cases:
* The click event action is not cancelled in the following cases:
* - The click event has a modifier (e.g. `metaKey`, `shiftKey`)
* - The click event is on an external link
* - The click event is on a link with `target="_blank"`
Expand All @@ -115,7 +115,7 @@ declare class SideNav extends SideNavChildrenMixin(FocusMixin(ElementMixin(Thema
*
* Also see the `location` property for updating the highlighted navigation item on route change.
*/
onNavigate?: ((event: OnNavigateProps) => boolean) | ((event: OnNavigateProps) => void);
onNavigate?: ((event: NavigateEvent) => boolean) | ((event: NavigateEvent) => void);

/**
* The current route of the application.
Expand Down
5 changes: 2 additions & 3 deletions packages/side-nav/src/vaadin-side-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class SideNav extends SideNavChildrenMixin(FocusMixin(ElementMixin(ThemableMixin
* When a side nav item link is clicked, this function is called and the default click action is cancelled.
* This delegates the responsibility of navigation to the function's logic.
*
* The click event is not cancelled in the following cases:
* The click event action is not cancelled in the following cases:
* - The click event has a modifier (e.g. `metaKey`, `shiftKey`)
* - The click event is on an external link
* - The click event is on a link with `target="_blank"`
Expand Down Expand Up @@ -139,10 +139,9 @@ class SideNav extends SideNavChildrenMixin(FocusMixin(ElementMixin(ThemableMixin
* This property should be kept in sync with the application's state. While it usually reflects the browser's URL,
* it can be set to any value. Changes to `location` update the highlighted item in the side navigation.
*
* @type {Object}
* @type {any}
*/
location: {
type: Object,
observer: '__locationChanged',
},
};
Expand Down
4 changes: 2 additions & 2 deletions packages/side-nav/test/typings/side-nav.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '../../vaadin-side-nav-item.js';
import type { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
import type { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
import type { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
import type { OnNavigateProps, SideNav, SideNavCollapsedChangedEvent, SideNavI18n } from '../../src/vaadin-side-nav';
import type { NavigateEvent, SideNav, SideNavCollapsedChangedEvent, SideNavI18n } from '../../src/vaadin-side-nav';
import type { SideNavChildrenMixinClass } from '../../src/vaadin-side-nav-children-mixin.js';
import type { SideNavItem, SideNavItemExpandedChangedEvent } from '../../src/vaadin-side-nav-item';

Expand Down Expand Up @@ -31,7 +31,7 @@ sideNav.addEventListener('collapsed-changed', (event) => {
sideNav.onNavigate = undefined;
sideNav.onNavigate = () => false;
sideNav.onNavigate = (event) => {
assertType<OnNavigateProps>(event);
assertType<NavigateEvent>(event);
assertType<string | null | undefined>(event.path);
assertType<string | null | undefined>(event.target);
assertType<boolean>(event.current);
Expand Down

0 comments on commit 8ca868f

Please sign in to comment.