fix(menus): one tick for every choice; a listbox holds its options only
- The saved views, the view switcher, the year filter and the table's single-choice filter mark the chosen row with MenuCheck, as DESIGN asks, not a trailing tick, a dot or a filled row; a contract test holds every checkable menu row to it. keepSelectedPaint had no caller left and is gone. - A combobox's panel carries its listbox role on an inner PopoverList (listInside), so the failed load, Loading, No matches and the 'n more' line sit beside the options, not inside the listbox. The Plex search box's Loading line likewise. - The Plex sidebar's playlist picker offers Create only once the lists have loaded: over a failed load it pushed the error and its Retry out at the first keystroke.
This commit is contained in:
@@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { ChevronDown } from "lucide-react";
|
||||
import { Button } from "./Button";
|
||||
import { MenuCheck } from "./MenuCheck";
|
||||
import { PopoverSurface, PopoverItem } from "./AnchoredPopover";
|
||||
import { PopoverItem, PopoverList, PopoverSurface } from "./AnchoredPopover";
|
||||
import { useAnchoredPopover } from "./anchoredPopoverHooks";
|
||||
import { useScrollFade } from "../../lib/useScrollFade";
|
||||
import { InnerInput } from "./Input";
|
||||
@@ -263,42 +263,15 @@ export default function Combobox({
|
||||
<PopoverSurface
|
||||
popover={pop}
|
||||
ariaLabel={label}
|
||||
listInside
|
||||
className={`${SURFACE.menu} w-full animate-[popIn_0.16s_ease]`}
|
||||
>
|
||||
{/* The scroll box owns the height cap AND the scroll-fade mask (ref+style on the same element). */}
|
||||
<div ref={fade.ref} style={fade.style} className="max-h-64 overflow-y-auto no-scrollbar">
|
||||
{showError ? (
|
||||
<div className="flex items-center gap-2 px-2 py-1.5">
|
||||
<p role="alert" className="flex-1 text-xs text-danger">
|
||||
{error}
|
||||
{onRetry && <span className="sr-only"> {t("common.retryWithEnter")}</span>}
|
||||
</p>
|
||||
{onRetry && (
|
||||
// For the pointer only: this panel is a listbox, which may hold options and nothing
|
||||
// else, so the keyboard's Retry is Enter in the field (said in the alert above).
|
||||
<Button
|
||||
variant="outline"
|
||||
size="xs"
|
||||
type="button"
|
||||
tabIndex={-1}
|
||||
aria-hidden
|
||||
// Keep the focus in the field: a press that moved it out would close the list.
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={onRetry}
|
||||
>
|
||||
{t("common.retry")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
) : loading && filtered.length === 0 ? (
|
||||
<p className="px-2 py-1.5 text-xs text-muted">{t("common.loading")}</p>
|
||||
) : filtered.length === 0 ? (
|
||||
<p className="px-2 py-1.5 text-xs text-muted">
|
||||
{emptyText ?? t("common.noResults", { defaultValue: "No matches" })}
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
{visible.map((o) => {
|
||||
{/* The listbox holds the options alone; the lines about the list sit beside it (F4). */}
|
||||
<PopoverList>
|
||||
{!showError &&
|
||||
visible.map((o) => {
|
||||
const on = selected.includes(o.value);
|
||||
return (
|
||||
<PopoverItem
|
||||
@@ -328,15 +301,45 @@ export default function Combobox({
|
||||
</PopoverItem>
|
||||
);
|
||||
})}
|
||||
{hiddenCount > 0 && (
|
||||
<p className="px-2 py-1.5 text-2xs text-muted">
|
||||
{t("common.moreRefine", {
|
||||
count: hiddenCount,
|
||||
defaultValue: "{{count}} more — refine with search",
|
||||
})}
|
||||
</p>
|
||||
</PopoverList>
|
||||
{showError ? (
|
||||
<div className="flex items-center gap-2 px-2 py-1.5">
|
||||
<p role="alert" className="flex-1 text-xs text-danger">
|
||||
{error}
|
||||
{onRetry && <span className="sr-only"> {t("common.retryWithEnter")}</span>}
|
||||
</p>
|
||||
{onRetry && (
|
||||
// For the pointer: the keyboard's Retry is Enter in the field (said in the alert
|
||||
// above), since the focus stays there the whole time the list is open.
|
||||
<Button
|
||||
variant="outline"
|
||||
size="xs"
|
||||
type="button"
|
||||
tabIndex={-1}
|
||||
aria-hidden
|
||||
// Keep the focus in the field: a press that moved it out would close the list.
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={onRetry}
|
||||
>
|
||||
{t("common.retry")}
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
</div>
|
||||
) : loading && filtered.length === 0 ? (
|
||||
<p className="px-2 py-1.5 text-xs text-muted">{t("common.loading")}</p>
|
||||
) : filtered.length === 0 ? (
|
||||
<p className="px-2 py-1.5 text-xs text-muted">
|
||||
{emptyText ?? t("common.noResults", { defaultValue: "No matches" })}
|
||||
</p>
|
||||
) : (
|
||||
hiddenCount > 0 && (
|
||||
<p className="px-2 py-1.5 text-2xs text-muted">
|
||||
{t("common.moreRefine", {
|
||||
count: hiddenCount,
|
||||
defaultValue: "{{count}} more — refine with search",
|
||||
})}
|
||||
</p>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
</PopoverSurface>
|
||||
|
||||
Reference in New Issue
Block a user