Skip to content

Commit 95e689d

Browse files
committed
refactor: update type annotations in tests and touch handlers for better type safety
style: improve focus styles in accessibility and focused items SCSS
1 parent d24ca0f commit 95e689d

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

src/components/__tests__/Menu.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ describe('Menu.vue', () => {
365365
const wrapper = mount(Menu, {
366366
props: {
367367
...defaultProps,
368-
data: null as any,
368+
data: null as unknown,
369369
},
370370
});
371371

@@ -384,7 +384,7 @@ describe('Menu.vue', () => {
384384
});
385385

386386
// Trigger error by setting invalid state
387-
wrapper.vm.menuItems = null as any;
387+
wrapper.vm.menuItems = null as unknown;
388388

389389
const menuWrapper = wrapper.find('.menu-wrapper');
390390
await menuWrapper.trigger('keyup', { key: 'ArrowDown' });
@@ -419,7 +419,7 @@ describe('Menu.vue', () => {
419419
});
420420

421421
const menuItems = wrapper.findAll('.menu-list-item');
422-
menuItems.forEach((item: any) => {
422+
menuItems.forEach((item: ReturnType<typeof wrapper.find>) => {
423423
if (!item.classes().includes('divider')) {
424424
expect(item.classes()).toContain('flip');
425425
}

src/components/__tests__/MenuCloseAnimation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2+
import { nextTick } from 'vue';
23
import { mount } from '@vue/test-utils';
34
import FloatMenu from '../index.vue';
4-
import { nextTick } from 'vue';
55

66
describe('Menu Close Animation', () => {
77
let wrapper;

src/components/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ export default defineComponent({
670670
}
671671
672672
/* Only apply focus style on non-selected/non-highlighted items */
673-
&:not(.selected):not(.highlight):focus-visible {
673+
&:not(.selected, .highlight):focus-visible {
674674
outline: 2px solid #007bff;
675675
}
676676
}

src/components/styles/accessibility.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
}
3737

3838
/* Only show outline when using keyboard navigation and not selected */
39-
&:not(.selected):not(.highlight) {
39+
&:not(.selected, .highlight) {
4040
outline: 2px solid #007bff;
4141
outline-offset: -2px;
4242
position: relative;

src/components/styles/focused-items.scss

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,32 @@ li.menu-list-item[role="menuitem"]:focus-visible {
1919
border-color: transparent !important;
2020
}
2121

22-
/* Ensure no borders on Edit button which has the specific highlight */
23-
.menu-list-item:has(.name:contains("Edit")):focus-visible {
24-
outline: none !important;
25-
border: none !important;
26-
box-shadow: none !important;
27-
}
28-
2922
/* Direct CSS override to remove the blue border completely */
3023
.menu-list-item {
3124
&:focus {
3225
outline: none !important;
3326
border-color: transparent !important;
3427
}
35-
28+
3629
&:focus-visible {
3730
outline: none !important;
3831
border-color: transparent !important;
3932
}
4033

41-
/* Keep the focus style only for keyboard navigation on non-highlighted items */
42-
&:not(.selected):not(.highlight):focus-visible {
34+
/* Ensure proper order of selectors to avoid specificity issues */
35+
&:not(.selected, .highlight):focus-visible {
4336
outline: 2px solid #007bff;
4437
outline-offset: -2px;
4538
}
4639
}
4740

41+
/* Ensure no borders on Edit button which has the specific highlight */
42+
.menu-list-item:has(.name:contains("Edit")):focus-visible {
43+
outline: none !important;
44+
border: none !important;
45+
box-shadow: none !important;
46+
}
47+
4848
/* Completely eliminate all double borders */
4949
.menu-wrapper [role="menuitem"].selected,
5050
.menu-wrapper [role="menuitem"].highlight {

touchHandlers.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,35 @@ interface SwipeData {
1212
// Mock implementations - replace with actual imports/implementations
1313
const menuActive = ref(false);
1414

15-
const handleTouchStart = (event: TouchEvent, callback: (touchEvent: TouchEventData) => void) => {
15+
const handleTouchStart = (_event: TouchEvent, _callback: (touchEvent: TouchEventData) => void) => {
1616
// Implementation needed
1717
};
1818

19-
const handleTouchMove = (event: TouchEvent) => {
19+
const handleTouchMove = (_event: TouchEvent) => {
2020
// Implementation needed
2121
};
2222

23-
const handleTouchEnd = (event: TouchEvent, callback: (touchEvent: TouchEventData) => void) => {
23+
const handleTouchEnd = (_event: TouchEvent, _callback: (touchEvent: TouchEventData) => void) => {
2424
// Implementation needed
2525
};
2626

27-
const handleDragStart = (event: TouchEvent) => {
27+
const handleDragStart = (_event: TouchEvent) => {
2828
// Implementation needed
2929
};
3030

3131
const handleDragMove = () => {
3232
// Implementation needed
3333
};
3434

35-
const handleDragEnd = (event: TouchEvent) => {
35+
const handleDragEnd = (_event: TouchEvent) => {
3636
// Implementation needed
3737
};
3838

39-
const triggerHapticFeedback = (intensity: 'light' | 'medium' | 'heavy') => {
39+
const triggerHapticFeedback = (_intensity: 'light' | 'medium' | 'heavy') => {
4040
// Implementation needed
4141
};
4242

43-
const toggleMenu = (event: TouchEvent) => {
43+
const toggleMenu = (_event: TouchEvent) => {
4444
// Implementation needed
4545
};
4646

@@ -54,7 +54,7 @@ const handleMenuClose = () => {
5454
};
5555

5656
// Enhanced touch handlers
57-
const handleEnhancedTouchStart = (event: TouchEvent) => {
57+
export const handleEnhancedTouchStart = (event: TouchEvent) => {
5858
handleTouchStart(event, (touchEvent: TouchEventData) => {
5959
if (touchEvent.type === 'longpress') {
6060
// Long press opens menu and provides haptic feedback
@@ -69,12 +69,12 @@ const handleEnhancedTouchStart = (event: TouchEvent) => {
6969
handleDragStart(event);
7070
};
7171

72-
const handleEnhancedTouchMove = (event: TouchEvent) => {
72+
export const handleEnhancedTouchMove = (event: TouchEvent) => {
7373
handleTouchMove(event);
7474
handleDragMove();
7575
};
7676

77-
const handleEnhancedTouchEnd = (event: TouchEvent) => {
77+
export const handleEnhancedTouchEnd = (event: TouchEvent) => {
7878
handleTouchEnd(event, (touchEvent: TouchEventData) => {
7979
if (touchEvent.type === 'tap') {
8080
// Provide light haptic feedback for taps

0 commit comments

Comments
 (0)