diff --git a/locales/en/mod_management.json b/locales/en/mod_management.json
index 8f59303b00..13a00fed21 100644
--- a/locales/en/mod_management.json
+++ b/locales/en/mod_management.json
@@ -212,8 +212,8 @@
"label": "Properties",
"general": "General",
"advanced": "Advanced",
- "close": "Close properties",
"toggle": "Properties",
+ "manageCategories": "Manage categories",
"open": "Properties",
"noSelection": "Select a mod to see its properties",
"count": "{{count}} mod selected",
@@ -221,7 +221,6 @@
"byAuthor": "by {{author}}",
"adult": "Adult",
"showDescription": "Show description",
- "hideDescription": "Hide description",
"copy": "Copy {{label}}",
"copied": "Copied to clipboard",
"copyFailed": "Couldn't copy to the clipboard",
diff --git a/src/renderer/src/extensions/category_management/index.ts b/src/renderer/src/extensions/category_management/index.ts
index 3b297412b2..c8b2114794 100644
--- a/src/renderer/src/extensions/category_management/index.ts
+++ b/src/renderer/src/extensions/category_management/index.ts
@@ -76,9 +76,16 @@ function init(context: IExtensionContext): boolean {
context.registerReducer(["persistent", "categories"], categoryReducer);
context.registerDialog("categories", CategoryDialog);
- context.registerAction("mod-icons", 80, "categories", { pinned: true }, "Categories", () => {
- context.api.store.dispatch(setDialogVisible("categories"));
- });
+ context.registerAction(
+ "mod-icons",
+ 80,
+ "categories",
+ { pinned: true },
+ "Manage categories",
+ () => {
+ context.api.store.dispatch(setDialogVisible("categories"));
+ },
+ );
context.registerTableAttribute("mods", {
id: "category",
diff --git a/src/renderer/src/extensions/mod_management/components/mod_properties_card/ModPropertiesCard.test.tsx b/src/renderer/src/extensions/mod_management/components/mod_properties_card/ModPropertiesCard.test.tsx
index ae45faa70b..8b169d7694 100644
--- a/src/renderer/src/extensions/mod_management/components/mod_properties_card/ModPropertiesCard.test.tsx
+++ b/src/renderer/src/extensions/mod_management/components/mod_properties_card/ModPropertiesCard.test.tsx
@@ -41,18 +41,51 @@ describe("ModPropertiesCard", () => {
expect(screen.getByTestId("mod-properties-card-footer")).toBeInTheDocument();
});
- it("shows its whole description a click away", async () => {
+ it("shows its whole description in a modal a click away", async () => {
renderCard({ name: "SkyUI", isAdult: false, description: "[b]An interface[/b]" });
- expect(screen.queryByTestId("mod-properties-description")).toBeNull();
+ expect(screen.queryByRole("dialog")).toBeNull();
await userEvent.click(screen.getByTestId("mod-properties-description-toggle"));
- expect(screen.getByTestId("mod-properties-description")).toBeInTheDocument();
+ const dialog = screen.getByRole("dialog");
+ expect(dialog).toContainElement(screen.getByTestId("mod-properties-description"));
expect(
screen.getByTestId("mod-properties-description").querySelector("b, strong"),
).not.toBeNull();
});
+ it("closes the description's modal", async () => {
+ renderCard({ name: "SkyUI", isAdult: false, description: "An interface" });
+ await userEvent.click(screen.getByTestId("mod-properties-description-toggle"));
+
+ await userEvent.keyboard("{Escape}");
+
+ expect(screen.queryByRole("dialog")).toBeNull();
+ });
+
+ it("stands in for images from outside Nexus Mods where the mod has a page", async () => {
+ renderCard({
+ name: "SkyUI",
+ isAdult: false,
+ description: "[img]https://i.imgur.com/a.png[/img]",
+ pageUrl: "https://www.nexusmods.com/skyrimspecialedition/mods/12604",
+ });
+ await userEvent.click(screen.getByTestId("mod-properties-description-toggle"));
+
+ expect(screen.getByTestId("external-image-placeholder")).toBeInTheDocument();
+ });
+
+ it("leaves out images from outside Nexus Mods where the mod has no page", async () => {
+ renderCard({
+ name: "SkyUI",
+ isAdult: false,
+ description: "[img]https://i.imgur.com/a.png[/img]",
+ });
+ await userEvent.click(screen.getByTestId("mod-properties-description-toggle"));
+
+ expect(screen.queryByTestId("external-image-placeholder")).toBeNull();
+ });
+
it("offers no description where it has none", () => {
renderCard({ name: "SkyUI", isAdult: false });
diff --git a/src/renderer/src/extensions/mod_management/components/mod_properties_card/ModPropertiesCard.tsx b/src/renderer/src/extensions/mod_management/components/mod_properties_card/ModPropertiesCard.tsx
index b178fe2ba0..27afd72c59 100644
--- a/src/renderer/src/extensions/mod_management/components/mod_properties_card/ModPropertiesCard.tsx
+++ b/src/renderer/src/extensions/mod_management/components/mod_properties_card/ModPropertiesCard.tsx
@@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next";
import { Button } from "@/ui/components/button/Button";
import { AdultAwareImage } from "@/ui/components/image/AdultAwareImage";
+import { Modal } from "@/ui/components/modal/Modal";
import { BBCode } from "@/ui/components/prose/bbcode/BBCode";
import { Typography } from "@/ui/components/typography/Typography";
@@ -15,10 +16,10 @@ interface IModPropertiesCardProps {
/**
* The mod as Browse's mod card shows one, heading the Properties panel: its picture with its
- * status tag, its name and summary, its whole description a click away, as the legacy pane has
- * it, then its author and whether it's adult. Its picture blurs as the user has asked, if it's
- * adult; a mod without one shows the broken picture icon, as its row's thumbnail does. The
- * description shows no images from outside Nexus Mods, as there's no room to stand in for them.
+ * status tag, its name and summary, its whole description a click away in a modal, then its
+ * author and whether it's adult. Its picture blurs as the user has asked, if it's adult; a mod
+ * without one shows the broken picture icon, as its row's thumbnail does. The description's images
+ * from outside Nexus Mods show as placeholders opening its page, or not at all without one.
*/
export const ModPropertiesCard = ({ card }: IModPropertiesCardProps) => {
const { t } = useTranslation("mod_management");
@@ -52,25 +53,39 @@ export const ModPropertiesCard = ({ card }: IModPropertiesCardProps) => {
{!!card.description && (
-
+ <>
setShowDescription(!showDescription)}
+ onClick={() => setShowDescription(true)}
>
- {showDescription
- ? t("modsTable::properties::hideDescription")
- : t("modsTable::properties::showDescription")}
+ {t("modsTable::properties::showDescription")}
- {showDescription && (
-
-
+
setShowDescription(false)}
+ >
+
+
- )}
-
+
+ >
)}
{(!!card.author || card.isAdult) && (
diff --git a/src/renderer/src/extensions/mod_management/components/mod_properties_panel/ModPropertiesPanel.test.tsx b/src/renderer/src/extensions/mod_management/components/mod_properties_panel/ModPropertiesPanel.test.tsx
index a2bdbeca1d..cd9bed8a1f 100644
--- a/src/renderer/src/extensions/mod_management/components/mod_properties_panel/ModPropertiesPanel.test.tsx
+++ b/src/renderer/src/extensions/mod_management/components/mod_properties_panel/ModPropertiesPanel.test.tsx
@@ -29,7 +29,7 @@ const ONE_MOD: IModProperties = {
summary: "A friendlier menu.",
author: "schlangster",
isAdult: false,
- status: "downloaded",
+ status: "update",
},
sections: [
{
@@ -73,16 +73,11 @@ const REGISTERED = {
values: {} as unknown as RegisteredValues,
};
-const renderPanel = (properties: IModProperties, onClose = vi.fn(), registered = REGISTERED) => {
+const renderPanel = (properties: IModProperties, registered = REGISTERED) => {
vi.mocked(useModProperties).mockReturnValue(properties);
return render(
-
+
,
);
};
@@ -137,7 +132,7 @@ const renderRegistered = (
},
],
};
- const open = () => renderPanel(properties, vi.fn(), registered);
+ const open = () => renderPanel(properties, registered);
return { view: open(), open, attribute, extension, externalData, values: registered.values };
};
@@ -158,7 +153,7 @@ describe("ModPropertiesPanel", () => {
const general = screen.getByRole("tabpanel");
expect(within(general).getByTestId("mod-properties-card")).toBeInTheDocument();
- expect(within(general).getByTestId("mod-status-downloaded")).toBeInTheDocument();
+ expect(within(general).getByTestId("mod-status-update")).toBeInTheDocument();
expect(within(general).getByTestId("mod-property-version")).toHaveTextContent("5.2");
expect(within(general).queryByTestId("mod-property-archiveName")).not.toBeInTheDocument();
});
@@ -175,6 +170,35 @@ describe("ModPropertiesPanel", () => {
expect(screen.queryByTestId("mod-properties-card")).not.toBeInTheDocument();
});
+ it("starts a tab it switches to at its top", async () => {
+ renderPanel(ONE_MOD);
+ const scrollArea = screen.getByTestId("mod-properties-scroll-area");
+ scrollArea.scrollTop = 400;
+
+ await userEvent.click(screen.getAllByRole("tab")[1]);
+
+ expect(scrollArea.scrollTop).toBe(0);
+ });
+
+ it("keeps its tabs out of what scrolls", () => {
+ renderPanel(ONE_MOD);
+
+ const scrollArea = screen.getByTestId("mod-properties-scroll-area");
+ expect(scrollArea).not.toContainElement(screen.getByRole("tablist"));
+ expect(scrollArea).toContainElement(screen.getByTestId("mod-properties-card"));
+ });
+
+ it("keeps several mods' count out of what scrolls", () => {
+ renderPanel({
+ count: 3,
+ sections: [{ id: "organise", tab: "general", layout: "list", properties: [CATEGORY] }],
+ });
+
+ const scrollArea = screen.getByTestId("mod-properties-scroll-area");
+ expect(scrollArea).not.toContainElement(screen.getByTestId("mod-properties-count"));
+ expect(scrollArea).toContainElement(screen.getByRole("button", { name: /^Category/ }));
+ });
+
it("has no Advanced tab with nothing on it", () => {
renderPanel({ ...ONE_MOD, sections: ONE_MOD.sections.filter(({ tab }) => tab === "general") });
@@ -306,13 +330,4 @@ describe("ModPropertiesPanel", () => {
expect(externalData).not.toHaveBeenCalled();
expect(tableHears).not.toHaveBeenCalled();
});
-
- it("closes", async () => {
- const onClose = vi.fn();
- renderPanel(ONE_MOD, onClose);
-
- await userEvent.click(screen.getByTestId("mod-properties-close"));
-
- expect(onClose).toHaveBeenCalledTimes(1);
- });
});
diff --git a/src/renderer/src/extensions/mod_management/components/mod_properties_panel/ModPropertiesPanel.tsx b/src/renderer/src/extensions/mod_management/components/mod_properties_panel/ModPropertiesPanel.tsx
index b86d95fd6e..07c098fda3 100644
--- a/src/renderer/src/extensions/mod_management/components/mod_properties_panel/ModPropertiesPanel.tsx
+++ b/src/renderer/src/extensions/mod_management/components/mod_properties_panel/ModPropertiesPanel.tsx
@@ -1,7 +1,6 @@
-import React, { useState } from "react";
+import React, { useRef, useState } from "react";
import { useTranslation } from "react-i18next";
-import { Button } from "@/ui/components/button/Button";
import { NoResults } from "@/ui/components/no_results/NoResults";
import { TabBar } from "@/ui/components/tabs/TabBar";
import { TabButton } from "@/ui/components/tabs/TabButton";
@@ -32,13 +31,20 @@ interface IModPropertiesPanelProps {
memberships: { [modId: string]: IMod[] };
/** The fields extensions registered for the legacy details pane. */
registered: IRegisteredDetails;
- onClose: () => void;
/** Classes for its frame, which the page sizes and places. */
className?: string;
}
const TABS: ModPropertiesTab[] = ["general", "advanced"];
+/** Its fixed header, its gutter lined up with its scroll area's, with room for focus rings. */
+const HEADER_CLASSES =
+ "-mt-1 mr-1.5 flex shrink-0 scrollbar-gutter-stable overflow-hidden pt-1 pr-1.5 pb-4 pl-5";
+
+/** Where its contents scroll and fade out at the foot, as Browse's mod details do. */
+const SCROLL_CLASSES =
+ "mr-1.5 min-h-0 flex-1 scrollbar-gutter-stable overflow-y-auto scroll-fade pr-1.5 pb-9 pl-5 scroll-fade-9";
+
/** The sections on a tab, ruled off from each other. */
const sectionsOn = (properties: IModProperties, tab: ModPropertiesTab) =>
properties.sections
@@ -49,13 +55,13 @@ const sectionsOn = (properties: IModProperties, tab: ModPropertiesTab) =>
* The selected mods' properties, beside the new Mods table, some of them to change. One mod's are
* on two tabs: General, headed by its card, and Advanced, left out while it has nothing. Several
* mods show their count and what they can all change, and none an empty state. The tab the user
- * picked stays as the selection changes, falling back to General where it's gone.
+ * picked stays as the selection changes, falling back to General where it's gone; switching tabs
+ * starts the new one at its top.
*/
export const ModPropertiesPanel = ({
mods,
memberships,
registered,
- onClose,
className,
}: IModPropertiesPanelProps) => {
const { t } = useTranslation("mod_management");
@@ -72,6 +78,7 @@ export const ModPropertiesPanel = ({
// show them. It's only ever beside the new table.
const versions = useExternalDataVersions(detailsOnly, true, values, true);
const [picked, setPicked] = useState
("general");
+ const tabScrollRef = useRef(null);
// Each written out, so the strings can be found.
const tabLabels: Record = {
@@ -86,28 +93,11 @@ export const ModPropertiesPanel = ({
);
const tab = tabs.includes(picked) ? picked : "general";
- const closeButton = (
-
- );
-
const body = () => {
if (properties.count === 0) {
return (
-
-
-
-
-
- {closeButton}
+
+
);
}
@@ -116,18 +106,18 @@ export const ModPropertiesPanel = ({
if (properties.count > 1) {
return (
<>
-
+
{t("modsTable::properties::count", { count: properties.count })}
-
- {closeButton}
{/* General's then Advanced's, in one run, as there are no tabs to put them on. */}
-
- {sectionsOn(properties, "general")}
- {sectionsOn(properties, "advanced")}
+
+
+ {sectionsOn(properties, "general")}
+ {sectionsOn(properties, "advanced")}
+
>
);
@@ -138,9 +128,14 @@ export const ModPropertiesPanel = ({
tab={tab}
tabListId="mod-properties"
tabType="secondary"
- onSetSelectedTab={(next) => setPicked(next as ModPropertiesTab)}
+ onSetSelectedTab={(next) => {
+ setPicked(next as ModPropertiesTab);
+ if (tabScrollRef.current) {
+ tabScrollRef.current.scrollTop = 0;
+ }
+ }}
>
-
+
{tabs.map((id) => (
))}
-
- {closeButton}
- {tabs.map((id) => (
-
- {id === "general" && !!properties.card && (
-
-
-
- )}
-
- {sectionsOn(properties, id)}
-
- ))}
+
+ {tabs.map((id) => (
+
+ {id === "general" && !!properties.card && (
+
+
+
+ )}
+
+ {sectionsOn(properties, id)}
+
+ ))}
+
);
};
@@ -174,7 +169,7 @@ export const ModPropertiesPanel = ({
return (
{body()}
diff --git a/src/renderer/src/extensions/mod_management/components/mod_property_notes/ModPropertyNotes.tsx b/src/renderer/src/extensions/mod_management/components/mod_property_notes/ModPropertyNotes.tsx
index 570da55d48..255ef710ee 100644
--- a/src/renderer/src/extensions/mod_management/components/mod_property_notes/ModPropertyNotes.tsx
+++ b/src/renderer/src/extensions/mod_management/components/mod_property_notes/ModPropertyNotes.tsx
@@ -5,16 +5,17 @@ import { TextAreaField } from "@/ui/components/form/text_area_field/TextAreaFiel
import type { ModProperty } from "../../hooks/use_mod_properties/useModProperties.hook";
import { useUnsavedDraft } from "../../hooks/use_unsaved_draft/useUnsavedDraft.hook";
-import { COMPACT_FIELD } from "../../util/compact_field/compactField";
+import { COMPACT_HINTS } from "../../util/compact_field/compactField";
interface IModPropertyNotesProps {
property: Extract;
}
/**
- * Notes, typed here and saved on leaving the box, to the mods they were typed for. The box starts
- * a line tall, as the design's input is, and grows with a long note up to 10rem, then scrolls.
- * One made again with typing unsaved saves it as it goes, to its own mods.
+ * Notes, typed here and saved on leaving the box, to the mods they were typed for. The box is the
+ * panel's full width and starts three lines tall, growing with a long note up to 10rem, then
+ * scrolls; the user can drag it taller or shorter within the same bounds. One made again with
+ * typing unsaved saves it as it goes, to its own mods.
*/
export const ModPropertyNotes = ({ property }: IModPropertyNotesProps) => {
const { t } = useTranslation("mod_management");
@@ -24,12 +25,12 @@ export const ModPropertyNotes = ({ property }: IModPropertyNotesProps) => {
return (
change(event.target.value)}
diff --git a/src/renderer/src/extensions/mod_management/components/mod_property_select/ModPropertySelect.test.tsx b/src/renderer/src/extensions/mod_management/components/mod_property_select/ModPropertySelect.test.tsx
index 9fb8f42afb..f44089c2c3 100644
--- a/src/renderer/src/extensions/mod_management/components/mod_property_select/ModPropertySelect.test.tsx
+++ b/src/renderer/src/extensions/mod_management/components/mod_property_select/ModPropertySelect.test.tsx
@@ -29,6 +29,30 @@ const open = () => userEvent.click(trigger());
const options = () => screen.getAllByRole("option");
describe("ModPropertySelect", () => {
+ it("has its action beside it, named for what it does", async () => {
+ const onClick = vi.fn();
+ render(
+ ,
+ );
+
+ const action = screen.getByTestId("mod-property-category-action");
+ expect(action).toHaveAccessibleName("Manage");
+ expect(action).not.toHaveAttribute("title");
+ await userEvent.hover(action);
+ expect(await screen.findByRole("tooltip")).toHaveTextContent("Manage");
+ await userEvent.click(action);
+
+ expect(onClick).toHaveBeenCalledTimes(1);
+ });
+
+ it("has no action unless it's given one", () => {
+ render( );
+
+ expect(screen.queryByTestId("mod-property-category-action")).toBeNull();
+ });
+
it("shows the pick and saves another", async () => {
const onChange = vi.fn();
render( );
diff --git a/src/renderer/src/extensions/mod_management/components/mod_property_select/ModPropertySelect.tsx b/src/renderer/src/extensions/mod_management/components/mod_property_select/ModPropertySelect.tsx
index 67f36b47ee..c3afb4dc70 100644
--- a/src/renderer/src/extensions/mod_management/components/mod_property_select/ModPropertySelect.tsx
+++ b/src/renderer/src/extensions/mod_management/components/mod_property_select/ModPropertySelect.tsx
@@ -1,6 +1,7 @@
import React from "react";
import { useTranslation } from "react-i18next";
+import { Button } from "@/ui/components/button/Button";
import { Description } from "@/ui/components/form/field/Description";
import { Field } from "@/ui/components/form/field/Field";
import { Label } from "@/ui/components/form/field/Label";
@@ -8,6 +9,7 @@ import { Listbox } from "@/ui/components/listbox/Listbox";
import { ListboxButton } from "@/ui/components/listbox/ListboxButton";
import { ListboxOption } from "@/ui/components/listbox/ListboxOption";
import { ListboxOptions } from "@/ui/components/listbox/ListboxOptions";
+import { Tooltip } from "@/ui/components/tooltip/Tooltip";
import type { ModProperty } from "../../hooks/use_mod_properties/useModProperties.hook";
@@ -18,7 +20,8 @@ interface IModPropertySelectProps {
/**
* A choice from a list, in the design system's dropdown, under its label with its hint. Its button
* says "Various" while the mods differ, which isn't offered to pick back, and a value saved that
- * isn't one of the choices as it is. Picking the choice it already has saves nothing.
+ * isn't one of the choices as it is, cut short at the design's 240px. Picking the choice it already
+ * has saves nothing. Its action, if it has one, is an icon button beside it.
*/
export const ModPropertySelect = ({ property }: IModPropertySelectProps) => {
const { t } = useTranslation("mod_management");
@@ -46,27 +49,39 @@ export const ModPropertySelect = ({ property }: IModPropertySelectProps) => {
{property.label}
{/* A field's control, as a select is, which spaces the label above it. */}
- {
- if (property.isVarious || value !== property.value) {
- property.onChange(value);
- }
- }}
- >
- {/* The design's 240px, a long category path cut short; the whole of it on hover. */}
-
- {shown}
-
+
+ {
+ if (property.isVarious || value !== property.value) {
+ property.onChange(value);
+ }
+ }}
+ >
+ {shown}
-
- {options.map(({ value, label }) => (
-
- ))}
-
-
+
+ {options.map(({ value, label }) => (
+
+ ))}
+
+
+
+ {!!property.action && (
+
+
+
+ )}
+
{!!property.hint && (
diff --git a/src/renderer/src/extensions/mod_management/components/mod_property_time/ModPropertyTime.test.tsx b/src/renderer/src/extensions/mod_management/components/mod_property_time/ModPropertyTime.test.tsx
index eb31d7787a..7e814269ac 100644
--- a/src/renderer/src/extensions/mod_management/components/mod_property_time/ModPropertyTime.test.tsx
+++ b/src/renderer/src/extensions/mod_management/components/mod_property_time/ModPropertyTime.test.tsx
@@ -1,4 +1,5 @@
import { act, render, screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
import React from "react";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
@@ -9,15 +10,10 @@ vi.mock("react-redux", () => ({
selector({ settings: { interface: { language: "en" } } }),
}));
-const renderTime = () =>
+const renderTime = (timestamp = Date.now() - 10_000) =>
render(
,
);
@@ -37,6 +33,21 @@ describe("ModPropertyTime", () => {
expect(screen.getByTestId("mod-property-installTime")).toHaveTextContent("seconds ago");
});
+ it("shows its full date and time on hover, not as a title", async () => {
+ // The tooltip places itself on animation frames, which fake timers hold back.
+ vi.useRealTimers();
+ const timestamp = Date.now() - 10_000;
+ renderTime(timestamp);
+ const shown = screen.getByTestId("mod-property-installTime").querySelector(".truncate")!;
+
+ expect(shown).not.toHaveAttribute("title");
+ await userEvent.hover(shown);
+
+ expect(await screen.findByRole("tooltip")).toHaveTextContent(
+ new Intl.DateTimeFormat("en", { dateStyle: "medium", timeStyle: "short" }).format(timestamp),
+ );
+ });
+
it("ages the time shown", () => {
renderTime();
diff --git a/src/renderer/src/extensions/mod_management/components/mod_property_time/ModPropertyTime.tsx b/src/renderer/src/extensions/mod_management/components/mod_property_time/ModPropertyTime.tsx
index 39e16ecfc4..f909d8a906 100644
--- a/src/renderer/src/extensions/mod_management/components/mod_property_time/ModPropertyTime.tsx
+++ b/src/renderer/src/extensions/mod_management/components/mod_property_time/ModPropertyTime.tsx
@@ -1,6 +1,9 @@
import React from "react";
import { useTranslation } from "react-i18next";
+import { useSelector } from "react-redux";
+import type { IState } from "@/types/IState";
+import { Tooltip } from "@/ui/components/tooltip/Tooltip";
import { Typography } from "@/ui/components/typography/Typography";
import { useRelativeTime } from "@/util/useRelativeTime";
@@ -13,23 +16,31 @@ interface IModPropertyTimeProps {
/**
* A time under its label, as the table's columns show one, relative to now, and ageing as it
- * stays on screen.
+ * stays on screen; its full date and time on hover, as Browse's mod card shows one.
*/
export const ModPropertyTime = ({ property }: IModPropertyTimeProps) => {
const { t } = useTranslation("common");
const text = useRelativeTime(property.timestamp, t);
+ const language = useSelector((state: IState) => state.settings.interface.language);
+ const stamp = new Intl.DateTimeFormat(language, {
+ dateStyle: "medium",
+ timeStyle: "short",
+ }).format(property.timestamp);
return (
-
- {text}
-
+
+
+
+ {text}
+
+
+
);
};
diff --git a/src/renderer/src/extensions/mod_management/components/mod_property_url/ModPropertyUrl.test.tsx b/src/renderer/src/extensions/mod_management/components/mod_property_url/ModPropertyUrl.test.tsx
index c2b9597ae5..8f6e9cadf2 100644
--- a/src/renderer/src/extensions/mod_management/components/mod_property_url/ModPropertyUrl.test.tsx
+++ b/src/renderer/src/extensions/mod_management/components/mod_property_url/ModPropertyUrl.test.tsx
@@ -53,6 +53,15 @@ describe("ModPropertyUrl", () => {
expect(onSave).not.toHaveBeenCalled();
});
+ it("names its open button in a tooltip, not a title", async () => {
+ render(website(vi.fn(), "https://example.com"));
+ const open = screen.getByTestId("mod-property-open-website");
+
+ expect(open).not.toHaveAttribute("title");
+ await userEvent.hover(open);
+ expect(await screen.findByRole("tooltip")).toBeInTheDocument();
+ });
+
it("opens a valid address in the browser, and nothing else", async () => {
const openUrl = vi.fn();
vi.stubGlobal("api", { ...window.api, shell: { openUrl } });
diff --git a/src/renderer/src/extensions/mod_management/components/mod_property_url/ModPropertyUrl.tsx b/src/renderer/src/extensions/mod_management/components/mod_property_url/ModPropertyUrl.tsx
index 043b033980..243548aaf2 100644
--- a/src/renderer/src/extensions/mod_management/components/mod_property_url/ModPropertyUrl.tsx
+++ b/src/renderer/src/extensions/mod_management/components/mod_property_url/ModPropertyUrl.tsx
@@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next";
import { Button } from "@/ui/components/button/Button";
import { TextField } from "@/ui/components/form/text_field/TextField";
+import { Tooltip } from "@/ui/components/tooltip/Tooltip";
import type { ModProperty } from "../../hooks/use_mod_properties/useModProperties.hook";
import { useUnsavedDraft } from "../../hooks/use_unsaved_draft/useUnsavedDraft.hook";
@@ -44,17 +45,19 @@ export const ModPropertyUrl = ({ property }: IModPropertyUrlProps) => {
onChange={(event) => change(event.target.value)}
/>
- window.api.shell.openUrl(draft)}
- />
+
+ window.api.shell.openUrl(draft)}
+ />
+
);
};
diff --git a/src/renderer/src/extensions/mod_management/components/mod_property_value/ModPropertyValue.test.tsx b/src/renderer/src/extensions/mod_management/components/mod_property_value/ModPropertyValue.test.tsx
index ef1238391e..16f74465ce 100644
--- a/src/renderer/src/extensions/mod_management/components/mod_property_value/ModPropertyValue.test.tsx
+++ b/src/renderer/src/extensions/mod_management/components/mod_property_value/ModPropertyValue.test.tsx
@@ -28,6 +28,15 @@ describe("ModPropertyValue", () => {
expect(screen.getByTestId("mod-property-nexusModId")).toHaveTextContent("1234");
});
+ it("names its copy button in a tooltip, not a title", async () => {
+ renderValue();
+ const copy = screen.getByTestId("mod-property-copy-nexusModId");
+
+ expect(copy).not.toHaveAttribute("title");
+ await userEvent.hover(copy);
+ expect(await screen.findByRole("tooltip")).toBeInTheDocument();
+ });
+
it("offers no copy where it isn't copyable", () => {
renderValue(false);
diff --git a/src/renderer/src/extensions/mod_management/components/mod_property_value/ModPropertyValue.tsx b/src/renderer/src/extensions/mod_management/components/mod_property_value/ModPropertyValue.tsx
index fdb250d952..2b4ec91505 100644
--- a/src/renderer/src/extensions/mod_management/components/mod_property_value/ModPropertyValue.tsx
+++ b/src/renderer/src/extensions/mod_management/components/mod_property_value/ModPropertyValue.tsx
@@ -3,6 +3,7 @@ import { toast } from "react-hot-toast";
import { useTranslation } from "react-i18next";
import { Button } from "@/ui/components/button/Button";
+import { Tooltip } from "@/ui/components/tooltip/Tooltip";
import { Typography } from "@/ui/components/typography/Typography";
import type { ModProperty } from "../../hooks/use_mod_properties/useModProperties.hook";
@@ -12,7 +13,10 @@ interface IModPropertyValueProps {
property: Extract;
}
-/** A value under its label, in body/SM medium, with a button to copy it where it offers one. */
+/**
+ * A value under its label, in body/SM medium, wrapping to show it whole, with a button to copy it
+ * where it offers one.
+ */
export const ModPropertyValue = ({ property }: IModPropertyValueProps) => {
const { t } = useTranslation("mod_management");
@@ -27,23 +31,24 @@ export const ModPropertyValue = ({ property }: IModPropertyValueProps) => {
{property.value}
{property.copyable && (
-
+
+
+
)}
);
diff --git a/src/renderer/src/extensions/mod_management/components/mods_table_switch/ModsTableSwitch.test.tsx b/src/renderer/src/extensions/mod_management/components/mods_table_switch/ModsTableSwitch.test.tsx
index eada83fe75..5da24de906 100644
--- a/src/renderer/src/extensions/mod_management/components/mods_table_switch/ModsTableSwitch.test.tsx
+++ b/src/renderer/src/extensions/mod_management/components/mods_table_switch/ModsTableSwitch.test.tsx
@@ -1767,10 +1767,10 @@ describe("ModsTableSwitch", () => {
expect(toggleIcon()).toHaveStyle({ fontVariationSettings: '"FILL" 0' });
});
- it("closes from its own button, and stays closed", async () => {
+ it("closes from the toolbar's button, and stays closed", async () => {
renderSwitch({ a: mod("a", "Alpha", true) }, undefined, { propertiesOpen: true });
- await userEvent.click(within(panel()!).getByTestId("mod-properties-close"));
+ await userEvent.click(toggle());
slideShut();
expect(panel()).toBeNull();
diff --git a/src/renderer/src/extensions/mod_management/components/mods_table_switch/ModsTableSwitch.tsx b/src/renderer/src/extensions/mod_management/components/mods_table_switch/ModsTableSwitch.tsx
index df142cfd5d..0ccce02a82 100644
--- a/src/renderer/src/extensions/mod_management/components/mods_table_switch/ModsTableSwitch.tsx
+++ b/src/renderer/src/extensions/mod_management/components/mods_table_switch/ModsTableSwitch.tsx
@@ -172,6 +172,9 @@ const nop = () => undefined;
* the filters hide is deselected while rendering, however it comes to be hidden, so nothing acts on
* a mod out of sight. With no rows to show, it says the search found nothing only when the filters
* left some for it, and otherwise that nothing matches the filters.
+ *
+ * The Properties panel is the new table's aside, pinned over its right edge; the columns scroll
+ * sideways clear of it when both don't fit. One title tooltip serves extension controls in both.
*/
export const ModsTableSwitch = ({
mods,
@@ -575,7 +578,7 @@ export const ModsTableSwitch = ({
onGroupFocused,
focusRowId: focusModId,
onRowFocused: onModFocused,
- className: "mb-2 min-w-0 flex-1",
+ className: "min-w-0 flex-1 [--nxm-table-end-padding:--spacing(2)]",
toolbar: (
openProperties("double_click"),
onHeaderOffsetChange: setHeaderOffset,
- // Over the panel too, as one bar for the page, so its toggle sits above the panel's edge; as
- // wide as the panel is, as it slides.
- toolbarOverhang: showProperties ? PROPERTIES_WIDTH : undefined,
+ asideWidth: showProperties ? PROPERTIES_WIDTH : undefined,
rowMenu: ({ mod, name }: IModRow, close: () => void) =>
multiSelected ? (
<>
@@ -661,13 +662,6 @@ export const ModsTableSwitch = ({
return (
<>
- {/*
- The panel beside the table, sliding in from the right as the table makes room for it; the
- toolbar spans both. A rule down its left from the table's header row, where it starts,
- under the toolbar, fading in at its top as no rule across meets it there; it sticks there
- as the rows scroll, as the header does, no taller than the page's scroller. It slides as
- fast as the app's transitions, so not with reduced motion.
- */}
- {/*
- One for every extension control's titles, in the table and the panel, as only one
- shows at a time; it adds no box of its own, so the two stay the page's flex items.
- */}
-
-
- {
- if (event.target === event.currentTarget && !showProperties) {
- setPanelMounted(false);
- }
- }}
- >
- {(showProperties || panelMounted) && (
- // Around the panel, as the hooks that work out its contents run in its own render.
- // Its error goes as the selection changes, as it may be only one mod's.
-
setPropertiesOpen(false)}
+ {
+ if (event.target === event.currentTarget && !showProperties) {
+ setPanelMounted(false);
+ }
+ }}
>
- setPropertiesOpen(false)}
- />
-
- )}
-
+ {(showProperties || panelMounted) && (
+ setPropertiesOpen(false)}
+ >
+
+
+ )}
+
+ }
+ />
diff --git a/src/renderer/src/extensions/mod_management/hooks/use_mod_properties/useModProperties.hook.ts b/src/renderer/src/extensions/mod_management/hooks/use_mod_properties/useModProperties.hook.ts
index 1ec1426e8a..5e620f7eca 100644
--- a/src/renderer/src/extensions/mod_management/hooks/use_mod_properties/useModProperties.hook.ts
+++ b/src/renderer/src/extensions/mod_management/hooks/use_mod_properties/useModProperties.hook.ts
@@ -4,8 +4,10 @@ import { useTranslation } from "react-i18next";
import { useSelector } from "react-redux";
import type { IDownload } from "@/extensions/download_management/types/IDownload";
+import { NEXUS_DOMAIN } from "@/extensions/nexus_integration/constants";
import type { IState } from "@/types/IState";
import type { ITableAttribute } from "@/types/ITableAttribute";
+import type { SymbolName } from "@/ui/components/icon/Icon";
import { preT } from "@/util/i18n";
import { modAuthor } from "../../components/mod_author/ModAuthor";
@@ -31,16 +33,27 @@ export interface IModPropertiesCard {
summary?: string;
/** Its whole description from the site, in BBCode, if it came with one. */
description?: string;
+ /** Its page on the site, if it came from Nexus Mods, where its description's images show. */
+ pageUrl?: string;
/** Its author, or its uploader where the author isn't known. */
author?: string;
/** Its picture from the site, if it came from one. */
pictureUrl?: string;
/** Whether the site marks it adult, so its picture blurs as the user has asked. */
isAdult: boolean;
- /** Its status tag: downloaded but not installed, or with an update out. */
+ /** Its status tag, for an update out. */
status?: ModStatus;
}
+/** An icon button beside a property's control. */
+export interface IModPropertyAction {
+ /** Its icon. */
+ icon: SymbolName;
+ /** What it does, as its tooltip and accessible name. */
+ label: string;
+ onClick: () => void;
+}
+
/** One of a select's choices: what it saves, and what the user reads. */
export interface IModPropertyChoice {
/** What picking it saves. */
@@ -92,6 +105,8 @@ export type ModProperty = IModPropertyBase &
required?: boolean;
/** Saves a pick, "" for none, to every selected mod. */
onChange: (value: string) => void;
+ /** An icon button beside the dropdown, such as one managing its choices. */
+ action?: IModPropertyAction;
}
| {
kind: "switch";
@@ -172,8 +187,8 @@ const valueProperty = (
id: string,
label: string,
value: string | undefined,
- copyable?: boolean,
-): ModProperty[] => (value ? [{ kind: "value", id, label, value, copyable }] : []);
+ options: { copyable?: boolean } = {},
+): ModProperty[] => (value ? [{ kind: "value", id, label, value, ...options }] : []);
/** A time as a property that ages on screen; none where there's no valid one. */
const timeProperty = (
@@ -181,15 +196,40 @@ const timeProperty = (
label: string,
value: string | number | Date | undefined,
): ModProperty[] => {
- const timestamp = value === undefined ? Number.NaN : new Date(value).getTime();
- return Number.isNaN(timestamp) ? [] : [{ kind: "time", id, label, timestamp }];
+ const timestamp = value ? new Date(value).getTime() : undefined;
+ if (!timestamp) {
+ return [];
+ }
+
+ return [{ kind: "time", id, label, timestamp }];
+};
+
+/** Whether an address is on Nexus Mods. */
+const isOnNexusMods = (address: string) => {
+ try {
+ const { hostname } = new URL(address);
+ return hostname === NEXUS_DOMAIN || hostname.endsWith(`.${NEXUS_DOMAIN}`);
+ } catch {
+ return false;
+ }
+};
+
+/** A Nexus Mods mod's page, as kept when it was downloaded; none for one from anywhere else. */
+const pageUrlOf = (mod: IModWithState) => {
+ const homepage = textOf(mod.attributes?.homepage);
+ if (mod.attributes?.source !== "nexus" || !homepage || !isOnNexusMods(homepage)) {
+ return undefined;
+ }
+
+ return homepage;
};
-/** The mod's card: its picture, status, name, summary and author. */
+/** The mod's card: its picture, status, name, summary, author and page. */
const cardOf = (mod: IModWithState): IModPropertiesCard => ({
name: displayName(mod),
summary: textOf(mod.attributes?.shortDescription),
description: textOf(mod.attributes?.description) || undefined,
+ pageUrl: pageUrlOf(mod),
author: modAuthor(mod),
pictureUrl: textOf(mod.attributes?.pictureUrl),
isAdult: mod.attributes?.adultContent === true,
@@ -222,7 +262,7 @@ const collectionIdProperties = (mod: IModWithState, t: TFunction) => {
"nexusCollectionId",
t("modsTable::properties::nexusCollectionId"),
id ?? t("modsTable::properties::notPublished"),
- id !== undefined,
+ { copyable: id !== undefined },
);
};
@@ -237,7 +277,7 @@ const linkProperties = (mod: IModWithState, memberships: IMod[], t: TFunction) =
mod.attributes?.source === "nexus" && mod.type !== "collection"
? textOf(mod.attributes?.modId)
: undefined,
- true,
+ { copyable: true },
),
...collectionIdProperties(mod, t),
...valueProperty(
@@ -258,7 +298,7 @@ const fileProperties = (mod: IModWithState, download: IDownload | undefined, t:
"nexusFileId",
t("modsTable::properties::nexusFileId"),
mod.attributes?.source === "nexus" ? textOf(mod.attributes?.fileId) : undefined,
- true,
+ { copyable: true },
),
];
diff --git a/src/renderer/src/extensions/mod_management/hooks/use_mod_properties/useModProperties.test.tsx b/src/renderer/src/extensions/mod_management/hooks/use_mod_properties/useModProperties.test.tsx
index c93ca81524..fadc875649 100644
--- a/src/renderer/src/extensions/mod_management/hooks/use_mod_properties/useModProperties.test.tsx
+++ b/src/renderer/src/extensions/mod_management/hooks/use_mod_properties/useModProperties.test.tsx
@@ -8,6 +8,7 @@ vi.mock("@/contexts", async (importOriginal) => ({
useMainContext: () => ({ api: { events: { emit: vi.fn() } } }),
}));
+import { NEXUS_BASE_URL } from "@/extensions/nexus_integration/constants";
import { makeModsTableStore } from "@/test-utils/modsTableStore";
import type { ITableAttribute } from "@/types/ITableAttribute";
import type { TFunction } from "@/util/i18n";
@@ -38,6 +39,7 @@ const SKYUI = mod("skyui", {
modId: 12604,
fileId: 35407,
variant: "Lite",
+ homepage: `${NEXUS_BASE_URL}/skyrimspecialedition/mods/12604/`,
},
});
@@ -80,13 +82,40 @@ describe("useModProperties", () => {
description: "[b]SkyUI[/b] is an interface mod.",
author: "schlangster",
pictureUrl: "https://example.com/skyui.png",
+ pageUrl: `${NEXUS_BASE_URL}/skyrimspecialedition/mods/12604/`,
isAdult: false,
status: undefined,
});
});
- it("tags a downloaded mod's card", () => {
- expect(renderProperties([mod("a", { state: "downloaded" })]).card?.status).toBe("downloaded");
+ it("has no page where the one it keeps isn't on Nexus Mods", () => {
+ const elsewhere = mod("skyui", {
+ attributes: { ...SKYUI.attributes, homepage: "https://example.com/skyui" },
+ });
+
+ expect(renderProperties([elsewhere]).card?.pageUrl).toBeUndefined();
+ });
+
+ it("has no page for a mod that isn't from Nexus Mods", () => {
+ const local = mod("local", {
+ attributes: { name: "Local", source: "website", homepage: `${NEXUS_BASE_URL}/x/mods/1` },
+ });
+
+ expect(renderProperties([local]).card?.pageUrl).toBeUndefined();
+ });
+
+ it("tags the card of a mod with an update out", () => {
+ const outdated = mod("a", {
+ attributes: {
+ source: "nexus",
+ fileId: 1,
+ version: "1.0",
+ newestVersion: "1.1",
+ newestFileId: 2,
+ },
+ });
+
+ expect(renderProperties([outdated]).card?.status).toBe("update");
});
it("puts its version and times side by side on General", () => {
@@ -104,6 +133,13 @@ describe("useModProperties", () => {
expect(propertyById(result, "version")).toMatchObject({ value: "5.2" });
});
+ // As a mod that's never been enabled keeps it, which would otherwise read as 1970.
+ it("leaves out a time of zero", () => {
+ const neverEnabled = mod("skyui", { ...SKYUI, enabledTime: 0 });
+
+ expect(propertyById(renderProperties([neverEnabled]), "enabledTime")).toBeUndefined();
+ });
+
it("lists a Nexus mod's ID on General, to copy", () => {
expect(propertyById(renderProperties([SKYUI]), "nexusModId")).toMatchObject({
tab: "general",
diff --git a/src/renderer/src/extensions/mod_management/hooks/use_mod_property_edits/useModPropertyEdits.hook.ts b/src/renderer/src/extensions/mod_management/hooks/use_mod_property_edits/useModPropertyEdits.hook.ts
index 8c985b4795..a610500ca0 100644
--- a/src/renderer/src/extensions/mod_management/hooks/use_mod_property_edits/useModPropertyEdits.hook.ts
+++ b/src/renderer/src/extensions/mod_management/hooks/use_mod_property_edits/useModPropertyEdits.hook.ts
@@ -2,6 +2,7 @@ import { useCallback, useMemo } from "react";
import { useTranslation } from "react-i18next";
import { useDispatch, useSelector } from "react-redux";
+import { setDialogVisible } from "@/actions/session";
import { categoryChoices } from "@/extensions/category_management/util/category_choices/categoryChoices";
import { activeGameId } from "@/util/selectors";
@@ -76,6 +77,11 @@ export const useModPropertyEdits = (mods: IModWithState[]): IModPropertyEdits =>
...modsSharedValue(mods, categoryOf),
choices: categories,
onChange: (value) => save("category", value),
+ action: {
+ icon: "sell",
+ label: t("modsTable::properties::manageCategories"),
+ onClick: () => dispatch(setDialogVisible("categories")),
+ },
},
...(allInstalled
? [
diff --git a/src/renderer/src/extensions/mod_management/hooks/use_mod_property_edits/useModPropertyEdits.test.tsx b/src/renderer/src/extensions/mod_management/hooks/use_mod_property_edits/useModPropertyEdits.test.tsx
index 43db24971a..5cf23db989 100644
--- a/src/renderer/src/extensions/mod_management/hooks/use_mod_property_edits/useModPropertyEdits.test.tsx
+++ b/src/renderer/src/extensions/mod_management/hooks/use_mod_property_edits/useModPropertyEdits.test.tsx
@@ -81,6 +81,22 @@ describe("useModPropertyEdits", () => {
]);
});
+ it("manages the categories from beside the category, in the categories dialog", () => {
+ const { edits, dispatch } = renderEdits([mod("a")]);
+ const category = byId(edits.organise, "category");
+
+ act(() => {
+ if (category.kind === "select") {
+ category.action?.onClick();
+ }
+ });
+
+ expect(category).toMatchObject({ action: { icon: "sell" } });
+ expect(dispatch.mock.calls.map(([action]) => action)).toMatchObject([
+ { type: "SET_DIALOG_VISIBLE", payload: { dialogId: "categories" } },
+ ]);
+ });
+
it("saves a note to the mods it's given, not whichever are selected", () => {
const { edits, dispatch } = renderEdits([mod("a", { notes: "old" })]);
const notes = byId(edits.organise, "notes");
diff --git a/src/renderer/src/extensions/mod_management/util/compact_field/compactField.ts b/src/renderer/src/extensions/mod_management/util/compact_field/compactField.ts
index 7949cd437a..ca056e90b0 100644
--- a/src/renderer/src/extensions/mod_management/util/compact_field/compactField.ts
+++ b/src/renderer/src/extensions/mod_management/util/compact_field/compactField.ts
@@ -1,7 +1,11 @@
/**
- * The design's compact fields: a 240px control, narrower than the panel, with 12px hints at its
- * full width, 8px under the control. The field components draw hints larger and controls full
- * width elsewhere, so the panel's own say so here, in one place.
+ * The design's compact hints: 12px at the field's full width, 8px under the control. The field
+ * components draw hints larger elsewhere, so the panel's own say so here, in one place.
*/
-export const COMPACT_FIELD =
- "[&_.nxm-field-control]:w-60 [&_.nxm-field-description]:text-body-sm [&_.nxm-field-footer]:mt-2";
+export const COMPACT_HINTS = "[&_.nxm-field-description]:text-body-sm [&_.nxm-field-footer]:mt-2";
+
+/**
+ * The design's compact fields: a 240px control, narrower than the panel, with compact hints. The
+ * field components draw controls full width elsewhere.
+ */
+export const COMPACT_FIELD = `[&_.nxm-field-control]:w-60 ${COMPACT_HINTS}`;
diff --git a/src/renderer/src/extensions/mod_management/util/mod_status/modStatus.test.ts b/src/renderer/src/extensions/mod_management/util/mod_status/modStatus.test.ts
index 76aa468d96..b293c29926 100644
--- a/src/renderer/src/extensions/mod_management/util/mod_status/modStatus.test.ts
+++ b/src/renderer/src/extensions/mod_management/util/mod_status/modStatus.test.ts
@@ -7,10 +7,6 @@ import { localModStatus } from "./modStatus";
const NEXUS = { source: "nexus", fileId: 100, version: "1.0" };
describe("localModStatus", () => {
- it("is downloaded for a mod that's downloaded but not installed", () => {
- expect(localModStatus(makeMod({ state: "downloaded" }))).toBe("downloaded");
- });
-
it("is update for an installed mod with a newer file out", () => {
const mod = makeMod({ attributes: { ...NEXUS, newestVersion: "1.1", newestFileId: 101 } });
diff --git a/src/renderer/src/extensions/mod_management/util/mod_status/modStatus.ts b/src/renderer/src/extensions/mod_management/util/mod_status/modStatus.ts
index 607e9935c3..07db34649c 100644
--- a/src/renderer/src/extensions/mod_management/util/mod_status/modStatus.ts
+++ b/src/renderer/src/extensions/mod_management/util/mod_status/modStatus.ts
@@ -30,15 +30,10 @@ export const modStatusDisplay = (t: TFunction, status: ModStatus): IModStatusDis
};
/**
- * The status to tag one of the user's own mods with: downloaded but not installed, or with an
- * update out. Never installed, which every other mod on the Mods page is, and nothing while it
- * installs.
+ * The status to tag one of the user's own mods with: an update out for one that's installed.
+ * Never installed or downloaded, which the Mods page shows its mods are already.
*/
export const localModStatus = (mod: IMod): ModStatus | undefined => {
- if (mod.state === "downloaded") {
- return "downloaded";
- }
-
if (mod.state === "installed" && modHasUpdate(mod)) {
return "update";
}
diff --git a/src/renderer/src/ui/components/table/Table.test.tsx b/src/renderer/src/ui/components/table/Table.test.tsx
index 2915fadf54..918e2a04f0 100644
--- a/src/renderer/src/ui/components/table/Table.test.tsx
+++ b/src/renderer/src/ui/components/table/Table.test.tsx
@@ -35,6 +35,12 @@ const COLUMNS: Array> = [
const renderTable = () =>
render( row.id} label="Files" rows={ROWS} />);
+/** The element that lays the grid out, which carries its tracks and styles. */
+const layoutOf = (grid: HTMLElement) => grid.parentElement as HTMLElement;
+
+/** The last track: the right gutter, and room for an aside. */
+const END_TRACK = "calc(var(--nxm-table-gutter) + var(--nxm-table-aside-width))";
+
describe("Table", () => {
it("is a grid named by its label, with a header row and a row per item", () => {
renderTable();
@@ -65,8 +71,8 @@ describe("Table", () => {
it("makes its tracks from the column widths, between the gutters", () => {
renderTable();
- expect(screen.getByRole("grid").style.gridTemplateColumns).toBe(
- "var(--nxm-table-gutter-start) minmax(280px, 1fr) 80px var(--nxm-table-gutter)",
+ expect(layoutOf(screen.getByRole("grid")).style.gridTemplateColumns).toBe(
+ `var(--nxm-table-gutter-start) minmax(280px, 1fr) 80px ${END_TRACK}`,
);
});
@@ -156,7 +162,7 @@ describe("Table", () => {
/>,
);
- const table = screen.getByRole("grid");
+ const table = layoutOf(screen.getByRole("grid"));
expect(table).toHaveAttribute("data-sticky-reveal");
expect(table.style.getPropertyValue("--nxm-table-sticky-reveal")).toBe("72px");
@@ -168,7 +174,7 @@ describe("Table", () => {
rows={ROWS}
/>,
);
- expect(screen.getByRole("grid")).not.toHaveAttribute("data-sticky-reveal");
+ expect(layoutOf(screen.getByRole("grid"))).not.toHaveAttribute("data-sticky-reveal");
});
// A sticky column fades what passes under it, so the table's edge needn't.
@@ -517,7 +523,9 @@ describe("Table with selectable rows", () => {
await userEvent.click(cell("Alpha"));
await clickWith("Gamma", "Control");
- await userEvent.click(screen.getByRole("grid"));
+ // On the element that lays the grid out, as a browser targets empty space: the grid adds
+ // no box of its own.
+ await userEvent.click(layoutOf(screen.getByRole("grid")));
expect(selected()).toEqual([]);
});
@@ -660,7 +668,7 @@ describe("Table with resizable columns", () => {
type Widths = { [columnId: string]: number | undefined };
- const tracks = () => (screen.getByRole("grid") as HTMLElement).style.gridTemplateColumns;
+ const tracks = () => layoutOf(screen.getByRole("grid")).style.gridTemplateColumns;
const renderResizable = ({
columns = RESIZABLE,
@@ -714,7 +722,7 @@ describe("Table with resizable columns", () => {
renderResizable({ columns: [COLUMNS[1]], resizes: false });
expect(screen.queryByRole("separator")).toBeNull();
- expect(tracks()).toBe("var(--nxm-table-gutter-start) 80px var(--nxm-table-gutter)");
+ expect(tracks()).toBe(`var(--nxm-table-gutter-start) 80px ${END_TRACK}`);
});
it("draws a column at the width it was resized to", () => {
@@ -839,25 +847,62 @@ describe("Table with a toolbar", () => {
expect(grid).toHaveAttribute("aria-rowcount", String(ROWS.length + 2));
});
- it("lets its toolbar reach past its right edge by the overhang it's given", () => {
- const renderWith = (toolbarOverhang?: `${number}rem`) => (
+ it("leaves the room it's given at the columns' right for an aside", () => {
+ const renderWith = (asideWidth?: `${number}rem`) => (
row.id}
label="Files"
rows={ROWS}
- toolbar={Search }
- toolbarOverhang={toolbarOverhang}
/>
);
const { rerender } = render(renderWith("27rem"));
- const overhang = () =>
- screen.getByRole("grid").style.getPropertyValue("--nxm-table-toolbar-overhang");
- expect(overhang()).toBe("27rem");
+ const layout = () => layoutOf(screen.getByRole("grid"));
+ expect(layout().style.getPropertyValue("--nxm-table-aside-width")).toBe("27rem");
+ expect(layout()).toHaveAttribute("data-aside");
rerender(renderWith());
- expect(overhang()).toBe("");
+ expect(layout().style.getPropertyValue("--nxm-table-aside-width")).toBe("");
+ expect(layout()).not.toHaveAttribute("data-aside");
+ });
+
+ it("lays its aside out with it but outside the grid", () => {
+ render(
+ Close}
+ columns={COLUMNS}
+ getRowId={(row) => row.id}
+ label="Files"
+ rows={ROWS}
+ />,
+ );
+
+ const grid = screen.getByRole("grid");
+ const close = screen.getByRole("button", { name: "Close" });
+ expect(grid).not.toContainElement(close);
+ expect(layoutOf(grid)).toContainElement(close);
+ });
+
+ it("keeps the selection when its aside is clicked", async () => {
+ const onSelectedIdsChange = vi.fn();
+ render(
+ Close}
+ columns={COLUMNS}
+ getRowId={(row) => row.id}
+ label="Files"
+ rows={ROWS}
+ selectable
+ selectedIds={new Set(["a"])}
+ onSelectedIdsChange={onSelectedIdsChange}
+ />,
+ );
+
+ await userEvent.click(screen.getByRole("button", { name: "Close" }));
+
+ expect(onSelectedIdsChange).not.toHaveBeenCalled();
});
it("tells how far below its top the header row starts, under the toolbar", () => {
@@ -1027,6 +1072,26 @@ describe("Table with groups", () => {
expect(screen.getAllByRole("row")).toHaveLength(6);
});
+
+ // So the sticky column's shadow runs on under the last row, whatever that row is.
+ it("has a strip for the sticky column's shadow below its rows, only with a sticky column", () => {
+ const { unmount } = renderGrouped();
+ expect(document.querySelector(".nxm-table-end")).toBeNull();
+ unmount();
+
+ render(
+ row.id}
+ groups={GROUPS}
+ label="Files"
+ />,
+ );
+
+ const strip = document.querySelector(".nxm-table-end");
+ expect(strip).toHaveAttribute("aria-hidden");
+ expect(screen.getByRole("treegrid")).not.toContainElement(strip as HTMLElement);
+ });
});
describe("Table in a scrolling page", () => {
diff --git a/src/renderer/src/ui/components/table/Table.tsx b/src/renderer/src/ui/components/table/Table.tsx
index 26b657d693..2563ce5d3c 100644
--- a/src/renderer/src/ui/components/table/Table.tsx
+++ b/src/renderer/src/ui/components/table/Table.tsx
@@ -36,6 +36,7 @@ import { TableGroupRow } from "./TableGroupRow";
import { TableHeader } from "./TableHeader";
import { TableRow } from "./TableRow";
import { TableSpacer } from "./TableSpacer";
+import { useScrollableRight } from "./use_scrollable_right/useScrollableRight.hook";
import { useTableSelection } from "./useTableSelection.hook";
import { useTableSort } from "./useTableSort.hook";
import { useTableVirtualizer } from "./useTableVirtualizer.hook";
@@ -69,6 +70,9 @@ const GROUP_ROW_GAP = 4;
* Given `focusGroupId`, it opens that group and scrolls it to the top once it has it; the group
* opens while rendering, so its rows are counted before it's scrolled to. `focusRowId` does the
* same for a row, opening the first group it's in, then selecting it alone.
+ *
+ * The grid role sits on a `display: contents` wrapper, so an `aside` shares the layout but not
+ * the grid. A click on its empty space, not the head or the aside, clears the selection.
*/
export const Table = = ITableGroup>({
columns,
@@ -77,7 +81,8 @@ export const Table = = ITableGroup>({
getRowId,
label,
toolbar,
- toolbarOverhang,
+ aside,
+ asideWidth,
footer,
empty,
defaultSort,
@@ -224,6 +229,7 @@ export const Table = = ITableGroup>({
getItemSize,
stickyIndexes,
});
+ useScrollableRight(virtual.scroller, virtual.tableRef);
const hasFocusGroup = !!focusGroupId && !!groups?.some((group) => group.id === focusGroupId);
@@ -276,7 +282,8 @@ export const Table = = ITableGroup>({
onRowFocused?.();
}, [focusRowId, getRowId, items, onRowFocused, onSelectedIdsChange, ready, scrollToIndex]);
- const revealWidth = columns.find((column) => column.sticky === "end")?.revealWidth;
+ const stickyEnd = columns.find((column) => column.sticky === "end");
+ const revealWidth = stickyEnd?.revealWidth;
// The rows in the sticky head, which come before the table's own in aria-rowindex.
const headRows = toolbar ? 2 : 1;
@@ -324,7 +331,7 @@ export const Table = = ITableGroup>({
[
"var(--nxm-table-gutter-start)",
...columnTracks(columns, (columnId) => widths[columnId], resizes),
- "var(--nxm-table-gutter)",
+ "calc(var(--nxm-table-gutter) + var(--nxm-table-aside-width))",
].join(" ");
const savedTemplate = template(columnWidths ?? {});
@@ -458,13 +465,12 @@ export const Table = = ITableGroup>({
return (
= ITableGroup
>({
"--nxm-table-group-row-gap": `${GROUP_ROW_GAP}px`,
"--nxm-table-sticky-reveal": revealWidth,
"--nxm-table-toolbar-height": toolbarHeight ? `${toolbarHeight}px` : undefined,
- "--nxm-table-toolbar-overhang": toolbarOverhang,
+ "--nxm-table-aside-width": asideWidth,
gridTemplateColumns: savedTemplate,
} as CSSProperties
}
- onBlur={virtual.onBlur}
onClick={(event) => {
- // Between and below the rows, but not the head; a portalled panel isn't in the table.
const target = event.target as Element;
if (
selectable &&
event.currentTarget.contains(target) &&
- target.closest('[role="row"], .nxm-table-head') === null
+ target.closest('[role="row"], .nxm-table-head, .nxm-table-aside') === null
) {
selection.clear();
}
}}
- onFocus={virtual.onFocus}
>
- {
- const element = tableRef.current;
- if (width === undefined) {
- dragWidthsRef.current = undefined;
- if (element) {
- element.style.gridTemplateColumns = savedTemplate;
- }
- return;
- }
-
- dragWidthsRef.current = {
- ...(dragWidthsRef.current ?? sharedWidths(columnId)),
- [columnId]: width,
- };
- if (element) {
- element.style.gridTemplateColumns = template({
- ...columnWidths,
- ...dragWidthsRef.current,
- });
- }
- }}
- onColumnResize={
- onColumnWidthsChange &&
- ((columnId, width) => {
- const column = columns.find(({ id }) => id === columnId);
- if (!column) {
- return;
- }
+
+
{
+ const element = tableRef.current;
if (width === undefined) {
- onColumnWidthsChange({ [columnId]: undefined });
+ dragWidthsRef.current = undefined;
+ if (element) {
+ element.style.gridTemplateColumns = savedTemplate;
+ }
return;
}
- const { [columnId]: _dragged, ...held } =
- dragWidthsRef.current ?? sharedWidths(columnId);
- onColumnWidthsChange({ ...held, [columnId]: keptWidth(column, width) });
- })
- }
- onSort={toggleSort}
- />
- {/* Always rendered, at the top of the rows: where the virtualiser measures from. */}
-
+ dragWidthsRef.current = {
+ ...(dragWidthsRef.current ?? sharedWidths(columnId)),
+ [columnId]: width,
+ };
+ if (element) {
+ element.style.gridTemplateColumns = template({
+ ...columnWidths,
+ ...dragWidthsRef.current,
+ });
+ }
+ }}
+ onColumnResize={
+ onColumnWidthsChange &&
+ ((columnId, width) => {
+ const column = columns.find(({ id }) => id === columnId);
+ if (!column) {
+ return;
+ }
+ if (width === undefined) {
+ onColumnWidthsChange({ [columnId]: undefined });
+ return;
+ }
+ const { [columnId]: _dragged, ...held } =
+ dragWidthsRef.current ?? sharedWidths(columnId);
+ onColumnWidthsChange({ ...held, [columnId]: keptWidth(column, width) });
+ })
+ }
+ onSort={toggleSort}
+ />
+
+ {/* Always rendered, at the top of the rows: where the virtualiser measures from. */}
+
- {!groups &&
- virtual.items.map(({ gap, index }) => (
-
- {/* Rows out of view, before a focused row kept far from the rest too. */}
-
+ {!groups &&
+ virtual.items.map(({ gap, index }) => (
+
+ {/* Rows out of view, before a focused row kept far from the rest too. */}
+
- {renderItem(index)}
-
- ))}
+ {renderItem(index)}
+
+ ))}
- {!!groups &&
- blocks.blocks.map(({ endGap, gap, heading, rows: blockRows }) => {
- const item = items[heading];
+ {!!groups &&
+ blocks.blocks.map(({ endGap, gap, heading, rows: blockRows }) => {
+ const item = items[heading];
- return (
-
-
+ return (
+
+
-
- {blockRows.map((row) => (
-
-
+
+ {blockRows.map((row) => (
+
+
- {renderItem(row.index)}
-
- ))}
+ {renderItem(row.index)}
+
+ ))}
-
-
-
- );
- })}
+
+
+
+ );
+ })}
-
+
- {showsEmpty && (
-
-
- {empty}
+ {showsEmpty && (
+
-
- )}
-
-
setMenu(undefined)}>
- {(close) => {
- if (menu?.kind === "group") {
- if (!menuGroup) {
- return null;
- }
+ )}
- return (
-
- );
- }
+ setMenu(undefined)}>
+ {(close) => {
+ if (menu?.kind === "group") {
+ if (!menuGroup) {
+ return null;
+ }
- return menuRow === undefined ? null : rowMenu?.(menuRow, close);
- }}
-
+ return (
+
+ );
+ }
- {!!footer && (
-
-
- {footer}
+ return menuRow === undefined ? null : rowMenu?.(menuRow, close);
+ }}
+
+
+ {!!footer && (
+
-
- )}
+ )}
+
+
+ {!!stickyEnd &&
}
+
+ {!!aside && {aside}
}
);
};
diff --git a/src/renderer/src/ui/components/table/Table.types.ts b/src/renderer/src/ui/components/table/Table.types.ts
index a9f2ec355c..8b2ed9e5df 100644
--- a/src/renderer/src/ui/components/table/Table.types.ts
+++ b/src/renderer/src/ui/components/table/Table.types.ts
@@ -64,13 +64,10 @@ export type ITableProps = ITableGroup> = {
label: string;
/** Controls above the header row, in the sticky head: a page's tabs and actions. */
toolbar?: ReactNode;
- /**
- * How far the toolbar reaches past the table's right edge, over a panel the page lays beside
- * the table under it, so its controls end where the panel does. Unset, it ends with the table.
- * It changes as fast as the app's transitions, so a panel sliding in at that speed keeps the
- * toolbar's width the same throughout.
- */
- toolbarOverhang?: `${number}rem`;
+ /** A panel pinned over the right edge, outside the grid, hung from the view's top right. */
+ aside?: ReactNode;
+ /** The room the columns leave at their right for `aside`. */
+ asideWidth?: `${number}rem`;
/** Along the bottom of the view, below the rows: a bar for the selected rows. */
footer?: ReactNode;
/** In place of the rows while there are none: what a search that matched nothing says. */
diff --git a/src/renderer/src/ui/components/table/table_column_resizer/TableColumnResizer.test.tsx b/src/renderer/src/ui/components/table/table_column_resizer/TableColumnResizer.test.tsx
index 141fb86775..caad2a9b80 100644
--- a/src/renderer/src/ui/components/table/table_column_resizer/TableColumnResizer.test.tsx
+++ b/src/renderer/src/ui/components/table/table_column_resizer/TableColumnResizer.test.tsx
@@ -1,11 +1,14 @@
-import { fireEvent, render, screen } from "@testing-library/react";
+import { act, fireEvent, render, screen } from "@testing-library/react";
import React from "react";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { TableColumnResizer } from "./TableColumnResizer";
-/** Renders the handle in a header cell drawn `drawn` px wide, in a table 1000px wide. */
-const renderResizer = (drawn = 200) => {
+/**
+ * Renders the handle in a header cell drawn `drawn` px wide, in a table 1000px wide that leaves
+ * `aside` px for an aside.
+ */
+const renderResizer = (drawn = 200, aside?: string) => {
vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockReturnValue({
width: drawn,
} as DOMRect);
@@ -13,7 +16,7 @@ const renderResizer = (drawn = 200) => {
const onDrag = vi.fn();
const onResize = vi.fn();
render(
-
+
@@ -41,6 +44,31 @@ describe("TableColumnResizer", () => {
expect(handle).toHaveAttribute("aria-valuetext");
});
+ it("goes no wider from the keyboard than the table leaves beside an aside", () => {
+ const { handle } = renderResizer(200, "424px");
+
+ expect(handle).toHaveAttribute("aria-valuemax", "576");
+ });
+
+ it("measures again once an aside has slid in, but not as the table's other transitions end", () => {
+ const { handle } = renderResizer(200, "424px");
+ const table = handle.closest
(".nxm-table")!;
+ const ended = (target: Element, propertyName: string) => {
+ const event = new Event("transitionend", { bubbles: true });
+ Object.defineProperty(event, "propertyName", { value: propertyName });
+ act(() => {
+ target.dispatchEvent(event);
+ });
+ };
+ vi.spyOn(HTMLElement.prototype, "clientWidth", "get").mockReturnValue(1200);
+
+ ended(handle, "opacity");
+ expect(handle).toHaveAttribute("aria-valuemax", "576");
+
+ ended(table, "--nxm-table-aside-width");
+ expect(handle).toHaveAttribute("aria-valuemax", "776");
+ });
+
it("reads as its least while its column is drawn narrower", () => {
const { handle } = renderResizer(40);
diff --git a/src/renderer/src/ui/components/table/table_column_resizer/TableColumnResizer.tsx b/src/renderer/src/ui/components/table/table_column_resizer/TableColumnResizer.tsx
index e1ceb2c68a..3c9f737b0c 100644
--- a/src/renderer/src/ui/components/table/table_column_resizer/TableColumnResizer.tsx
+++ b/src/renderer/src/ui/components/table/table_column_resizer/TableColumnResizer.tsx
@@ -16,11 +16,20 @@ interface ITableColumnResizerProps {
onResize: (width: number | undefined) => void;
}
+/** The room the table leaves for an aside over its right edge, in px. */
+const asideWidthOf = (table: HTMLElement | null | undefined) => {
+ if (!table) {
+ return 0;
+ }
+
+ return parseFloat(getComputedStyle(table).getPropertyValue("--nxm-table-aside-width")) || 0;
+};
+
/**
* The handle on a resizable column's header edge, resizing it as `useResizeHandle` does: no
* narrower than its least; dragged, as wide as wanted, but from the keyboard no wider than the
- * table's visible width, which End takes it to. Read as a separator whose value is the width
- * the column's drawn at, in px.
+ * table's visible width less any aside over it, which End takes it to. Read as a separator
+ * whose value is the width the column's drawn at, in px.
*/
export const TableColumnResizer = ({
header,
@@ -39,15 +48,27 @@ export const TableColumnResizer = ({
return undefined;
}
- const measure = () =>
- setSize({
- drawn: Math.round(cell.getBoundingClientRect().width),
- table: Math.round(table?.clientWidth ?? 0),
+ const measure = () => {
+ const drawn = Math.round(cell.getBoundingClientRect().width);
+ const width = Math.round((table?.clientWidth ?? 0) - asideWidthOf(table));
+ setSize((size) => {
+ if (size.drawn === drawn && size.table === width) {
+ return size;
+ }
+
+ return { drawn, table: width };
});
+ };
+ const onTransitionEnd = (event: TransitionEvent) => {
+ if (event.target === table && event.propertyName === "--nxm-table-aside-width") {
+ measure();
+ }
+ };
measure();
+ table?.addEventListener("transitionend", onTransitionEnd);
if (typeof ResizeObserver === "undefined") {
- return undefined;
+ return () => table?.removeEventListener("transitionend", onTransitionEnd);
}
const observer = new ResizeObserver(measure);
@@ -55,7 +76,10 @@ export const TableColumnResizer = ({
if (table) {
observer.observe(table);
}
- return () => observer.disconnect();
+ return () => {
+ observer.disconnect();
+ table?.removeEventListener("transitionend", onTransitionEnd);
+ };
}, []);
const drawn = Math.max(minWidth, size.drawn);
diff --git a/src/renderer/src/ui/components/table/useTableVirtualizer.hook.ts b/src/renderer/src/ui/components/table/useTableVirtualizer.hook.ts
index aabcdc0884..0ec8c59538 100644
--- a/src/renderer/src/ui/components/table/useTableVirtualizer.hook.ts
+++ b/src/renderer/src/ui/components/table/useTableVirtualizer.hook.ts
@@ -202,6 +202,7 @@ export const useTableVirtualizer = ({
onBlur,
onFocus,
ready: scroller !== undefined,
+ scroller,
scrollToIndex,
startRef,
tableRef,
diff --git a/src/renderer/src/ui/components/table/use_scrollable_right/useScrollableRight.hook.ts b/src/renderer/src/ui/components/table/use_scrollable_right/useScrollableRight.hook.ts
new file mode 100644
index 0000000000..23a42f3b70
--- /dev/null
+++ b/src/renderer/src/ui/components/table/use_scrollable_right/useScrollableRight.hook.ts
@@ -0,0 +1,59 @@
+import { type RefObject, useLayoutEffect } from "react";
+
+/** Set while the scroller has further to go right. */
+export const SCROLLABLE_RIGHT = "data-scrollable-right";
+
+/**
+ * Marks the table while its scroller can scroll right, on the element and only on change, so
+ * reaching an edge restyles only what the attribute's rules pick out and nothing re-renders.
+ * Widths are measured only on resize; a scroll reads only how far left it is.
+ */
+export const useScrollableRight = (
+ scroller: HTMLElement | null | undefined,
+ tableRef: RefObject,
+) => {
+ useLayoutEffect(() => {
+ const table = tableRef.current;
+ if (!scroller || !table) {
+ return;
+ }
+
+ let maxLeft = 0;
+ let lastLeft: number | undefined;
+
+ const update = () => {
+ const left = scroller.scrollLeft;
+ if (left === lastLeft) {
+ return;
+ }
+ lastLeft = left;
+ const scrollable = left < maxLeft;
+ if (table.hasAttribute(SCROLLABLE_RIGHT) !== scrollable) {
+ table.toggleAttribute(SCROLLABLE_RIGHT, scrollable);
+ }
+ };
+
+ const measure = () => {
+ maxLeft = scroller.scrollWidth - scroller.clientWidth - 1;
+ lastLeft = undefined;
+ update();
+ };
+
+ measure();
+ scroller.addEventListener("scroll", update, { passive: true });
+
+ const observer =
+ typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(measure);
+ observer?.observe(scroller);
+ const header = table.querySelector(".nxm-table-header");
+ if (header) {
+ observer?.observe(header);
+ }
+
+ return () => {
+ scroller.removeEventListener("scroll", update);
+ observer?.disconnect();
+ table.removeAttribute(SCROLLABLE_RIGHT);
+ };
+ }, [scroller, tableRef]);
+};
diff --git a/src/renderer/src/ui/components/table/use_scrollable_right/useScrollableRight.test.tsx b/src/renderer/src/ui/components/table/use_scrollable_right/useScrollableRight.test.tsx
new file mode 100644
index 0000000000..fe18b03c4a
--- /dev/null
+++ b/src/renderer/src/ui/components/table/use_scrollable_right/useScrollableRight.test.tsx
@@ -0,0 +1,58 @@
+import { renderHook } from "@testing-library/react";
+import { describe, expect, it } from "vitest";
+
+import { SCROLLABLE_RIGHT, useScrollableRight } from "./useScrollableRight.hook";
+
+/** A scroller of the given widths, scrolled to `scrollLeft`, with the table in it. */
+const setup = (scrollWidth: number, clientWidth: number, scrollLeft = 0) => {
+ const scroller = document.createElement("div");
+ const table = document.createElement("div");
+ scroller.append(table);
+ Object.defineProperty(scroller, "scrollWidth", { value: scrollWidth, configurable: true });
+ Object.defineProperty(scroller, "clientWidth", { value: clientWidth, configurable: true });
+ scroller.scrollLeft = scrollLeft;
+ return { scroller, table, tableRef: { current: table } };
+};
+
+describe("useScrollableRight", () => {
+ it("marks the table while its scroller has further to go right", () => {
+ const { scroller, table, tableRef } = setup(1400, 1000);
+
+ renderHook(() => useScrollableRight(scroller, tableRef));
+
+ expect(table).toHaveAttribute(SCROLLABLE_RIGHT);
+ });
+
+ it("leaves it unmarked when everything fits", () => {
+ const { scroller, table, tableRef } = setup(1000, 1000);
+
+ renderHook(() => useScrollableRight(scroller, tableRef));
+
+ expect(table).not.toHaveAttribute(SCROLLABLE_RIGHT);
+ });
+
+ it("clears the mark once scrolled to the end, and puts it back on scrolling away", () => {
+ const { scroller, table, tableRef } = setup(1400, 1000);
+ renderHook(() => useScrollableRight(scroller, tableRef));
+
+ scroller.scrollLeft = 400;
+ scroller.dispatchEvent(new Event("scroll"));
+ expect(table).not.toHaveAttribute(SCROLLABLE_RIGHT);
+
+ scroller.scrollLeft = 100;
+ scroller.dispatchEvent(new Event("scroll"));
+ expect(table).toHaveAttribute(SCROLLABLE_RIGHT);
+ });
+
+ it("clears the mark once it's gone, and stops listening", () => {
+ const { scroller, table, tableRef } = setup(1400, 1000);
+ const { unmount } = renderHook(() => useScrollableRight(scroller, tableRef));
+
+ unmount();
+ expect(table).not.toHaveAttribute(SCROLLABLE_RIGHT);
+
+ scroller.scrollLeft = 100;
+ scroller.dispatchEvent(new Event("scroll"));
+ expect(table).not.toHaveAttribute(SCROLLABLE_RIGHT);
+ });
+});
diff --git a/src/stylesheets/ui/elements/table.css b/src/stylesheets/ui/elements/table.css
index c273a02bca..7fe423011e 100644
--- a/src/stylesheets/ui/elements/table.css
+++ b/src/stylesheets/ui/elements/table.css
@@ -1,6 +1,6 @@
-/* A length, so it can transition: see the toolbar's overhang below. Its initial value is in px,
- as a registered one must not depend on the font size. */
-@property --nxm-table-toolbar-overhang {
+/* A length, so it can transition: see the aside below. Its initial value is in px, as a
+ registered one must not depend on the font size. */
+@property --nxm-table-aside-width {
syntax: "";
inherits: true;
initial-value: 0px;
@@ -30,18 +30,21 @@
);
--nxm-table-row-tint: transparent;
--nxm-table-footer-height: calc(var(--spacing) * 10 + 1px);
+ /* Room under the last row, inside the table. */
+ --nxm-table-end-padding: 0px;
position: relative;
isolation: isolate;
display: grid;
align-content: start;
column-gap: var(--nxm-table-gap);
+ padding-bottom: var(--nxm-table-end-padding);
min-width: 0;
container-type: inline-size;
overflow-y: clip;
overflow-anchor: none;
- /* At the speed a panel beside the table slides, so the toolbar over both keeps its width. */
- transition-property: --nxm-table-toolbar-overhang;
+ /* At the speed an aside slides in, so the columns make room for it as it comes. */
+ transition-property: --nxm-table-aside-width;
transition-timing-function: var(--default-transition-timing-function);
transition-duration: var(--default-transition-duration);
}
@@ -86,9 +89,7 @@
/* The width in view, stuck to its left edge, so it stays put while the columns scroll
sideways under it. Padded by the gutter and gap, so its first tab lines up with the
- first column; its last control sits by the gutter alone, under the page header's.
- Wider by the overhang a page gives it, over a panel beside the table: the table clips
- only what's below it, so this shows. */
+ first column; its last control lines up under the page header's, over an aside. */
.nxm-table-toolbar {
position: sticky;
left: 0;
@@ -96,9 +97,9 @@
grid-row: 1;
grid-column: 1 / -1;
justify-self: start;
- width: calc(100cqi + var(--nxm-table-toolbar-overhang));
+ width: 100cqi;
height: var(--nxm-table-toolbar-height);
- padding-right: var(--nxm-table-gutter);
+ padding-right: calc(var(--nxm-table-gutter) + var(--nxm-table-gap));
padding-left: calc(var(--nxm-table-gutter-start) + var(--nxm-table-gap));
}
@@ -111,9 +112,9 @@
grid-row: 2;
}
- /* The width in view, stuck to its left edge like the toolbar, so its fade stays on the
- right of what's in view, over the right gutter, while there are columns to scroll to.
- Down to the scroller's foot, the table clipping it. */
+ /* The width in view, less an aside's, stuck to its left edge like the toolbar, so its fade
+ stays on the right of what's in view, over the right gutter, while there are columns to
+ scroll to. Down to the scroller's foot, the table clipping it. */
.nxm-table-edge {
position: sticky;
left: 0;
@@ -121,7 +122,7 @@
grid-column: 1 / -1;
place-self: start;
z-index: 2;
- width: 100cqi;
+ width: calc(100cqi - var(--nxm-table-aside-width));
height: 0;
pointer-events: none;
@@ -141,10 +142,23 @@
}
/* Only while the page's scroller has further to go right. */
- @container scroll-state(scrollable: right) {
- .nxm-table-edge::after {
- opacity: 1;
- }
+ .nxm-table[data-scrollable-right] .nxm-table-edge::after {
+ opacity: 1;
+ }
+
+ /* A zero-size point pinned at the view's top right, spanning every column so it sticks as
+ far as they scroll, that an aside hangs from. */
+ .nxm-table-aside {
+ position: sticky;
+ top: 0;
+ right: 0;
+ z-index: 5;
+ grid-row: 1;
+ grid-column: 1 / -1;
+ place-self: start end;
+ width: 0;
+ height: 0;
+ pointer-events: none;
}
/* As tall as its controls, not stretched to the row, so the table can measure it as they
@@ -243,8 +257,8 @@
scroll-margin-top: var(--nxm-table-head-height);
}
- .nxm-table[role="treegrid"] .nxm-table-row,
- .nxm-table[role="treegrid"] .nxm-table-row * {
+ .nxm-table[data-grouped] .nxm-table-row,
+ .nxm-table[data-grouped] .nxm-table-row * {
scroll-margin-top: calc(var(--nxm-table-head-height) + var(--nxm-table-group-row-height));
}
@@ -501,13 +515,13 @@
}
}
- /* Pinned at the right of what's in view, solid in its row's tint so the columns pass
- under it, covering the gutter to its right and fading them out to its left. */
+ /* Pinned at the right of what's in view, left of an aside, solid in its row's tint so the
+ columns pass under it, covering the gutter to its right and fading them out to its left. */
.nxm-table-cell[data-sticky="end"] {
/* The last column's track, past any gap the table puts before it. */
grid-column-end: -2;
position: sticky;
- right: calc(var(--nxm-table-gutter) + var(--nxm-table-gap));
+ right: calc(var(--nxm-table-gutter) + var(--nxm-table-gap) + var(--nxm-table-aside-width));
z-index: 2;
align-self: stretch;
--nxm-table-sticky-bg:
@@ -553,9 +567,43 @@
}
}
- /* The fade runs on through the head's padding and the gap above a group, unbroken. */
+ /* The fade runs on through the head's padding and the gap above a group, unbroken; its
+ shadow fades in over the top 3rem, the head's colour over the shadow alone. */
.nxm-table-header .nxm-table-cell[data-sticky="end"]::before {
bottom: calc(-1 * var(--nxm-table-head-padding));
+ background:
+ linear-gradient(to bottom, var(--color-surface-low), transparent 3rem) 0 0 /
+ var(--nxm-table-sticky-fade) 100% no-repeat,
+ linear-gradient(
+ to right,
+ transparent,
+ var(--color-scrim-300) var(--nxm-table-sticky-fade),
+ transparent var(--nxm-table-sticky-fade)
+ ),
+ var(--nxm-table-sticky-bg);
+ }
+
+ /* The sticky column's shadow run on through the room under the last row, in its track and
+ pinned with it, without any row's tint. Of no height itself, so the room stays the same. */
+ .nxm-table-end {
+ grid-column-end: -2;
+ position: sticky;
+ right: calc(var(--nxm-table-gutter) + var(--nxm-table-gap) + var(--nxm-table-aside-width));
+ z-index: 2;
+ height: var(--nxm-table-end-padding);
+ margin-bottom: calc(-1 * var(--nxm-table-end-padding));
+ pointer-events: none;
+
+ &::before {
+ content: "";
+ position: absolute;
+ inset-block: 0;
+ right: calc(100% + var(--nxm-table-sticky-solid));
+ width: var(--nxm-table-sticky-fade);
+ background: linear-gradient(to right, transparent, var(--color-scrim-300));
+ mask-image: linear-gradient(to right, transparent, #000);
+ opacity: 0;
+ }
}
.nxm-table-group-row .nxm-table-cell[data-sticky="end"]::before {
@@ -573,15 +621,16 @@
100% calc(100% - var(--nxm-table-group-row-gap) - 1px);
}
- /* The fade only while the page's scroller has further to go right. */
- @container scroll-state(scrollable: right) {
- .nxm-table-cell[data-sticky="end"]::before {
+ /* The fade only while the page's scroller has further to go right, as the table says. */
+ .nxm-table[data-scrollable-right] {
+ .nxm-table-cell[data-sticky="end"]::before,
+ .nxm-table-end::before {
opacity: 1;
}
/* A row's pins sit clear of the shadow the column casts, on every row, so they don't
move as a row is left. */
- .nxm-table[data-sticky-reveal]
+ &[data-sticky-reveal]
.nxm-table-row
.nxm-toolbar-group
> [data-toolbar-control]:has(+ :not([data-toolbar-control])) {
@@ -590,7 +639,7 @@
/* A widened row keeps the shadow at the column's edge, under its pins, so it runs on
unbroken down the column. */
- .nxm-table[data-sticky-reveal]
+ &[data-sticky-reveal]
.nxm-table-row:is(
:hover,
:has(:focus-visible),
@@ -627,7 +676,7 @@
.nxm-table-empty-cell {
position: sticky;
left: 0;
- width: 100cqi;
+ width: calc(100cqi - var(--nxm-table-aside-width));
padding-block: calc(var(--spacing) * 12);
}
@@ -649,7 +698,7 @@
.nxm-table-footer-cell {
position: sticky;
left: 0;
- width: 100cqi;
+ width: calc(100cqi - var(--nxm-table-aside-width));
height: 100%;
}
@@ -669,4 +718,9 @@
border-bottom-left-radius: var(--radius-lg);
background-color: var(--color-surface-mid);
}
+
+ /* Square where it meets an aside rather than the page's corner. */
+ .nxm-table[data-aside] .nxm-table-selection-bar {
+ border-bottom-right-radius: 0;
+ }
}