diff --git a/src/apps/modern/features/libraries/components/AlphabetPicker.tsx b/src/apps/modern/features/libraries/components/AlphabetPicker.tsx index 254380b3c4..9a8b23fe26 100644 --- a/src/apps/modern/features/libraries/components/AlphabetPicker.tsx +++ b/src/apps/modern/features/libraries/components/AlphabetPicker.tsx @@ -41,12 +41,18 @@ const AlphabetPicker: React.FC = ({ // eslint-disable-next-line react/jsx-no-bind sx={theme => ({ position: 'fixed', - top: '112px', // This is the height of the AppBar + Tabs, this should be dynamic + top: { + xs: '144px', // Extra small screens the AppBar wraps to 3 rows (128px) and we align top with 16px of spacing + sm: '96px' // Small screens the AppBar is 2 rows (96px) and we align center (no extra spacing) + }, bottom: 0, fontSize: '80%', display: 'flex', - alignItems: 'center', - // This should render under the main AppBar but above the ItemsView AppBar + alignItems: { + xs: 'start', + sm: 'center' + }, + // This should render under the main AppBar if overlapping zIndex: theme.zIndex.appBar - 1 })} > @@ -64,8 +70,14 @@ const AlphabetPicker: React.FC = ({ value={l} sx={{ borderWidth: 0, - paddingTop: 0.25, - paddingBottom: 0.25, + paddingTop: { + xs: 0, + md: 0.25 + }, + paddingBottom: { + xs: 0, + md: 0.25 + }, paddingLeft: 0.5, paddingRight: 0.5 }} diff --git a/src/apps/modern/features/libraries/components/ItemsView.tsx b/src/apps/modern/features/libraries/components/ItemsView.tsx index 629fb6281d..546fd4c903 100644 --- a/src/apps/modern/features/libraries/components/ItemsView.tsx +++ b/src/apps/modern/features/libraries/components/ItemsView.tsx @@ -20,6 +20,7 @@ import { LibraryTab } from 'types/libraryTab'; import type { ListOptions } from 'types/listOptions'; import AlphabetPicker from './AlphabetPicker'; +import useMediaQuery from '@mui/material/useMediaQuery'; const ItemsView: FC = () => { const { @@ -35,6 +36,14 @@ const ItemsView: FC = () => { // eslint-disable-next-line @typescript-eslint/no-unused-vars const setLibraryViewSettings = setViewSettings ?? ((action: SetStateAction) => { /* no-op */ }); const { isAlphabetPickerEnabled, noItemsMessage } = content ?? {}; + // Check if the alphabet picker will fit in the current viewport + const isAlphabetPickerSupported = useMediaQuery(t => [ + // Extra small screens have no padding around letters but larger AppBar + `${t.breakpoints.down('sm')} and (min-height: 575px)`, + // Small screens have padding around letters but smaller AppBar + // NOTE: Helper methods down/up add "@media" to the query string so use the value directly + `(min-width: ${t.breakpoints.values.sm}px) and (min-height: 610px)` + ].join(', ')); const { __legacyApiClient__, user } = useApi(); @@ -182,7 +191,7 @@ const ItemsView: FC = () => { return ( - {isAlphabetPickerEnabled && hasSortName && ( + {isAlphabetPickerSupported && isAlphabetPickerEnabled && hasSortName && ( { return ( { > {isBtnPlayAllEnabled && ( { {isBtnFilterEnabled && ( = ({ return (