Skip to content

Commit 2b76104

Browse files
committed
Cleaned up the SongContextMenu a little bit (just a little). Bug appears gone?
1 parent 38e36b7 commit 2b76104

File tree

5 files changed

+32
-21
lines changed

5 files changed

+32
-21
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"react-scripts": "^5.0.1",
106106
"react-test-renderer": "^17.0.2",
107107
"svg-react-loader": "^0.4.6",
108+
"tree-kill": "^1.2.2",
108109
"ts-jest": "29.1.1",
109110
"typescript": "^5.3.3",
110111
"vite": "^5.0.10",

src/UI/SongMenus.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { AddSongs, PlaySongs } from '../Recoil/api';
2424
import { SongListDetailClick } from './DetailPanel/Clickers';
2525
import { ErrorBoundary } from './Utilities';
2626

27-
export type SongListMenuData = { data: string; spot: Point };
27+
export type SongListMenuData = { data: string; spot?: Point };
2828

2929
type SongListMenuArgs = {
3030
title?: string;
@@ -109,7 +109,9 @@ export function SongListMenu({
109109
const likeNum = useRecoilValue(songLikeNumFromStringFuncFam(context.data));
110110
const likeIcons = ['Like', 'LikeSolid', 'Like', 'More'];
111111
const hateIcons = ['Dislike', 'Dislike', 'DislikeSolid', 'More'];
112-
112+
if (context.data === '' || context.spot === undefined) {
113+
return <></>;
114+
}
113115
const realItems: IContextualMenuItem[] = title
114116
? [{ key: 'Header', name: title, itemType: ContextualMenuItemType.Header }]
115117
: [];
@@ -162,14 +164,14 @@ export function SongListMenu({
162164
realItems.push(itm);
163165
}
164166
}
165-
166167
return (
167168
<ErrorBoundary>
168169
<ContextualMenu
169-
directionalHint={DirectionalHint.bottomRightEdge}
170+
directionalHint={DirectionalHint.bottomCenter}
170171
isBeakVisible={true}
171-
hidden={context.data === ''}
172172
items={realItems}
173+
shouldFocusOnMount={true}
174+
shouldFocusOnContainer={true}
173175
target={context.spot}
174176
onDismiss={(ev) => {
175177
// The DetailsList panel wiggles. A lot.
@@ -179,7 +181,8 @@ export function SongListMenu({
179181
onClearContext();
180182
}
181183
}}
182-
styles={{ container: { margin: 0, padding: 0, fontSize: 'small' } }}
184+
// Hide the scroll bar on the menu
185+
styles={{ container: { overflow: 'hidden' } }}
183186
/>
184187
</ErrorBoundary>
185188
);

src/UI/Views/Albums.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
SelectionMode,
1111
Text,
1212
} from '@fluentui/react';
13+
import { CurrentView } from '@freik/emp-shared';
1314
import { AlbumKey, Song } from '@freik/media-core';
1415
import { hasFieldType, isDefined, isNumber } from '@freik/typechk';
1516
import {
@@ -24,7 +25,6 @@ import {
2425
useRecoilValue,
2526
useResetRecoilState,
2627
} from 'recoil';
27-
import { CurrentView } from '@freik/emp-shared';
2828
import { AddSongs, SongListFromKey } from '../../Recoil/api';
2929
import { albumCoverUrlFuncFam } from '../../Recoil/ImageUrls';
3030
import { focusedKeysFuncFam } from '../../Recoil/KeyBuffer';
@@ -88,15 +88,15 @@ function AlbumHeaderDisplay({ group }: AHDProps): JSX.Element {
8888
);
8989
const onRightClick = useMyTransaction(
9090
({ set }) =>
91-
(event: React.MouseEvent<HTMLElement, MouseEvent>) =>
92-
set(albumContextState, {
93-
data: group.key,
94-
spot: { left: event.clientX + 14, top: event.clientY },
95-
}),
91+
(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
92+
const data = group.key;
93+
const spot = { left: event.clientX + 14, top: event.clientY };
94+
set(albumContextState, { data, spot });
95+
},
9696
);
9797

9898
return (
99-
<div className="album-header">
99+
<div className="album-header" onContextMenu={onRightClick}>
100100
<IconButton
101101
iconProps={{
102102
iconName: group.isCollapsed ? 'ChevronRight' : 'ChevronDown',
@@ -106,7 +106,6 @@ function AlbumHeaderDisplay({ group }: AHDProps): JSX.Element {
106106
<div
107107
className="album-header-info"
108108
onDoubleClick={onAddSongsClick}
109-
onContextMenu={onRightClick}
110109
style={{ padding: '2px 0px', cursor: 'pointer' }}
111110
>
112111
<Image
@@ -153,10 +152,9 @@ export function GroupedAlbumList(): JSX.Element {
153152
hasFieldType(ev, 'clientX', isNumber) &&
154153
hasFieldType(ev, 'clientY', isNumber)
155154
) {
156-
set(albumContextState, {
157-
data: item.key,
158-
spot: { left: ev.clientX + 14, top: ev.clientY },
159-
});
155+
const data = item.key;
156+
const spot = { left: ev.clientX + 14, top: ev.clientY };
157+
set(albumContextState, { data, spot });
160158
}
161159
},
162160
);

src/UI/Views/Artists.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
SelectionMode,
1111
Text,
1212
} from '@fluentui/react';
13+
import { CurrentView } from '@freik/emp-shared';
1314
import { Album, AlbumKey, Artist, ArtistKey } from '@freik/media-core';
1415
import {
1516
MakeSetState,
@@ -23,7 +24,6 @@ import {
2324
useRecoilValue,
2425
useResetRecoilState,
2526
} from 'recoil';
26-
import { CurrentView } from '@freik/emp-shared';
2727
import { AddSongs, SongListFromKey } from '../../Recoil/api';
2828
import { artistImageUrlFuncFam } from '../../Recoil/ImageUrls';
2929
import { focusedKeysFuncFam } from '../../Recoil/KeyBuffer';
@@ -92,7 +92,7 @@ function ArtistHeaderDisplay({ group }: { group: IGroup }): JSX.Element {
9292
);
9393
const songCount = artist.songs.length;
9494
return (
95-
<div className="artist-header">
95+
<div className="artist-header" onContextMenu={onRightClick}>
9696
<IconButton
9797
iconProps={{
9898
iconName: group.isCollapsed ? 'ChevronRight' : 'ChevronDown',
@@ -102,7 +102,6 @@ function ArtistHeaderDisplay({ group }: { group: IGroup }): JSX.Element {
102102
<div
103103
className="artist-header-info"
104104
onDoubleClick={onAddSongsClick}
105-
onContextMenu={onRightClick}
106105
style={{ padding: '2px 0px', cursor: 'pointer' }}
107106
>
108107
<Image

yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12358,6 +12358,7 @@ __metadata:
1235812358
recoil: "npm:^0.7.7"
1235912359
rimraf: "npm:^5.0.5"
1236012360
svg-react-loader: "npm:^0.4.6"
12361+
tree-kill: "npm:^1.2.2"
1236112362
ts-jest: "npm:29.1.1"
1236212363
typescript: "npm:^5.3.3"
1236312364
vite: "npm:^5.0.10"
@@ -23831,6 +23832,15 @@ __metadata:
2383123832
languageName: node
2383223833
linkType: hard
2383323834

23835+
"tree-kill@npm:^1.2.2":
23836+
version: 1.2.2
23837+
resolution: "tree-kill@npm:1.2.2"
23838+
bin:
23839+
tree-kill: cli.js
23840+
checksum: 49117f5f410d19c84b0464d29afb9642c863bc5ba40fcb9a245d474c6d5cc64d1b177a6e6713129eb346b40aebb9d4631d967517f9fbe8251c35b21b13cd96c7
23841+
languageName: node
23842+
linkType: hard
23843+
2383423844
"trim-newlines@npm:^2.0.0":
2383523845
version: 2.0.0
2383623846
resolution: "trim-newlines@npm:2.0.0"

0 commit comments

Comments
 (0)