Skip to content

Commit

Permalink
Cleaned up the SongContextMenu a little bit (just a little). Bug appe…
Browse files Browse the repository at this point in the history
…ars gone?
  • Loading branch information
kevinfrei committed Dec 29, 2023
1 parent 38e36b7 commit 0fd48e3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
15 changes: 9 additions & 6 deletions src/UI/SongMenus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { AddSongs, PlaySongs } from '../Recoil/api';
import { SongListDetailClick } from './DetailPanel/Clickers';
import { ErrorBoundary } from './Utilities';

export type SongListMenuData = { data: string; spot: Point };
export type SongListMenuData = { data: string; spot?: Point };

type SongListMenuArgs = {
title?: string;
Expand Down Expand Up @@ -109,7 +109,9 @@ export function SongListMenu({
const likeNum = useRecoilValue(songLikeNumFromStringFuncFam(context.data));
const likeIcons = ['Like', 'LikeSolid', 'Like', 'More'];
const hateIcons = ['Dislike', 'Dislike', 'DislikeSolid', 'More'];

if (context.data === '' || context.spot === undefined) {
return <></>;
}
const realItems: IContextualMenuItem[] = title
? [{ key: 'Header', name: title, itemType: ContextualMenuItemType.Header }]
: [];
Expand Down Expand Up @@ -162,14 +164,14 @@ export function SongListMenu({
realItems.push(itm);
}
}

return (
<ErrorBoundary>
<ContextualMenu
directionalHint={DirectionalHint.bottomRightEdge}
directionalHint={DirectionalHint.bottomCenter}
isBeakVisible={true}
hidden={context.data === ''}
items={realItems}
shouldFocusOnMount={true}
shouldFocusOnContainer={true}
target={context.spot}
onDismiss={(ev) => {
// The DetailsList panel wiggles. A lot.
Expand All @@ -179,7 +181,8 @@ export function SongListMenu({
onClearContext();
}
}}
styles={{ container: { margin: 0, padding: 0, fontSize: 'small' } }}
// Hide the scroll bar on the menu
styles={{ container: { overflow: 'hidden' } }}
/>
</ErrorBoundary>
);
Expand Down
22 changes: 10 additions & 12 deletions src/UI/Views/Albums.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
SelectionMode,
Text,
} from '@fluentui/react';
import { CurrentView } from '@freik/emp-shared';
import { AlbumKey, Song } from '@freik/media-core';
import { hasFieldType, isDefined, isNumber } from '@freik/typechk';
import {
Expand All @@ -24,7 +25,6 @@ import {
useRecoilValue,
useResetRecoilState,
} from 'recoil';
import { CurrentView } from '@freik/emp-shared';
import { AddSongs, SongListFromKey } from '../../Recoil/api';
import { albumCoverUrlFuncFam } from '../../Recoil/ImageUrls';
import { focusedKeysFuncFam } from '../../Recoil/KeyBuffer';
Expand Down Expand Up @@ -88,15 +88,15 @@ function AlbumHeaderDisplay({ group }: AHDProps): JSX.Element {
);
const onRightClick = useMyTransaction(
({ set }) =>
(event: React.MouseEvent<HTMLElement, MouseEvent>) =>
set(albumContextState, {
data: group.key,
spot: { left: event.clientX + 14, top: event.clientY },
}),
(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
const data = group.key;
const spot = { left: event.clientX + 14, top: event.clientY };
set(albumContextState, { data, spot });
},
);

return (
<div className="album-header">
<div className="album-header" onContextMenu={onRightClick}>
<IconButton
iconProps={{
iconName: group.isCollapsed ? 'ChevronRight' : 'ChevronDown',
Expand All @@ -106,7 +106,6 @@ function AlbumHeaderDisplay({ group }: AHDProps): JSX.Element {
<div
className="album-header-info"
onDoubleClick={onAddSongsClick}
onContextMenu={onRightClick}
style={{ padding: '2px 0px', cursor: 'pointer' }}
>
<Image
Expand Down Expand Up @@ -153,10 +152,9 @@ export function GroupedAlbumList(): JSX.Element {
hasFieldType(ev, 'clientX', isNumber) &&
hasFieldType(ev, 'clientY', isNumber)
) {
set(albumContextState, {
data: item.key,
spot: { left: ev.clientX + 14, top: ev.clientY },
});
const data = item.key;
const spot = { left: ev.clientX + 14, top: ev.clientY };
set(albumContextState, { data, spot });
}
},
);
Expand Down
5 changes: 2 additions & 3 deletions src/UI/Views/Artists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
SelectionMode,
Text,
} from '@fluentui/react';
import { CurrentView } from '@freik/emp-shared';
import { Album, AlbumKey, Artist, ArtistKey } from '@freik/media-core';
import {
MakeSetState,
Expand All @@ -23,7 +24,6 @@ import {
useRecoilValue,
useResetRecoilState,
} from 'recoil';
import { CurrentView } from '@freik/emp-shared';
import { AddSongs, SongListFromKey } from '../../Recoil/api';
import { artistImageUrlFuncFam } from '../../Recoil/ImageUrls';
import { focusedKeysFuncFam } from '../../Recoil/KeyBuffer';
Expand Down Expand Up @@ -92,7 +92,7 @@ function ArtistHeaderDisplay({ group }: { group: IGroup }): JSX.Element {
);
const songCount = artist.songs.length;
return (
<div className="artist-header">
<div className="artist-header" onContextMenu={onRightClick}>
<IconButton
iconProps={{
iconName: group.isCollapsed ? 'ChevronRight' : 'ChevronDown',
Expand All @@ -102,7 +102,6 @@ function ArtistHeaderDisplay({ group }: { group: IGroup }): JSX.Element {
<div
className="artist-header-info"
onDoubleClick={onAddSongsClick}
onContextMenu={onRightClick}
style={{ padding: '2px 0px', cursor: 'pointer' }}
>
<Image
Expand Down

0 comments on commit 0fd48e3

Please sign in to comment.