Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

Remove checkboxes from Files UI (#8159)

James Brunton0fcc00ac4f2a
diff --git a/frontend/editor/src/core/components/filesPage/FileGrid.accessibility.test.tsx b/frontend/editor/src/core/components/filesPage/FileGrid.accessibility.test.tsx
index db717174fa..17002449a5 100644
--- a/frontend/editor/src/core/components/filesPage/FileGrid.accessibility.test.tsx
+++ b/frontend/editor/src/core/components/filesPage/FileGrid.accessibility.test.tsx
@@ -72,6 +72,27 @@ describe("file library accessibility", () => {
expect(screen.getByRole("listitem", { name: "README" })).toBeVisible();
});
+ it("marks selected list rows without giving them checkboxes", () => {
+ const other = createNewStirlingFileStub(new File(["text"], "notes.pdf"));
+ render(
+ grid({
+ viewMode: "list",
+ entries: [
+ { kind: "file", file: stored },
+ { kind: "file", file: other },
+ ],
+ selectedFileIds: new Set([stored.id, other.id]),
+ onSetSelection: () => {},
+ }),
+ );
+ const [header, ...rows] = screen.getAllByRole("row");
+ expect(within(header).getByRole("checkbox")).toBeChecked();
+ for (const row of rows) {
+ expect(row).toHaveAttribute("aria-selected", "true");
+ expect(within(row).queryByRole("checkbox")).not.toBeInTheDocument();
+ }
+ });
+
it("announces native picker selection through its label and checkbox", () => {
render(
grid({
diff --git a/frontend/editor/src/core/components/filesPage/FileGrid.tsx b/frontend/editor/src/core/components/filesPage/FileGrid.tsx
index c979aa4850..c5409bf07b 100644
--- a/frontend/editor/src/core/components/filesPage/FileGrid.tsx
+++ b/frontend/editor/src/core/components/filesPage/FileGrid.tsx
@@ -314,7 +314,12 @@ export function FileGrid(props: FileGridProps & { loading?: boolean }) {
}, []);
if (loading && entries.length === 0) {
- return <SkeletonGrid viewMode={viewMode} />;
+ return (
+ <SkeletonGrid
+ viewMode={viewMode}
+ selectionColumn={Boolean(props.picker)}
+ />
+ );
}
const emptyState =
@@ -352,7 +357,13 @@ export function FileGrid(props: FileGridProps & { loading?: boolean }) {
);
}
-function SkeletonGrid({ viewMode }: { viewMode: FilesPageViewMode }) {
+function SkeletonGrid({
+ viewMode,
+ selectionColumn,
+}: {
+ viewMode: FilesPageViewMode;
+ selectionColumn: boolean;
+}) {
const placeholders = Array.from({ length: 6 });
if (viewMode === "list") {
return (
@@ -363,7 +374,7 @@ function SkeletonGrid({ viewMode }: { viewMode: FilesPageViewMode }) {
>
{placeholders.map((_, i) => (
<div key={i} className="files-page-list-row files-page-skeleton-row">
- <span />
+ {selectionColumn && <span />}
<span
className="files-page-skeleton-bar"
style={{ width: "60%" }}
@@ -617,7 +628,7 @@ function GridView({
multiSelectActive={
!picker?.foldersOnly &&
(Boolean(picker) ||
- selectedFileIds.size >= (touchSelection ? 1 : 2))
+ (touchSelection && selectedFileIds.size > 0))
}
touchSelection={touchSelection}
downloadAvailable={Boolean(onDownloadFile)}
@@ -646,6 +657,7 @@ function GridView({
interface FolderItemProps {
selectionOnly?: boolean;
+ selectionColumn?: boolean;
folder: FolderRecord;
fileCount: number;
@@ -1438,6 +1450,39 @@ function ListView({
},
});
+ const selectAll =
+ onSetSelection && visibleCount > 0 ? (
+ <Checkbox
+ checked={allSelected}
+ indeterminate={someSelected}
+ disabled={picker?.selectionDisabled}
+ onChange={(event) => {
+ // A click clears the native mixed state even when the pick limit prevents a selection change.
+ event.currentTarget.indeterminate = someSelected;
+ if (picker) {
+ const next = new Set(selectedFileIds);
+ for (const id of visibleFileIds) {
+ if (allSelected) next.delete(id);
+ else next.add(id);
+ }
+ onSetSelection(next);
+ picker.onSetDiskSelection(allSelected ? [] : visibleDiskFiles);
+ } else {
+ onSetSelection(allSelected ? new Set() : new Set(visibleFileIds));
+ }
+ }}
+ aria-label={
+ allSelected
+ ? t("filesPage.deselectAll", "Clear selection")
+ : t("filesPage.selectAll", "Select all")
+ }
+ />
+ ) : null;
+
+ // Touch selection toggles on tap, so its rows gain checkboxes from the first pick.
+ const touchSelecting = touchSelection && selectedFileIds.size > 0;
+ const selectionColumn = Boolean(picker) || touchSelecting;
+
const { range, padTop, padBottom, setContainer } = useVirtualFileRows(
entries.length,
rowHeightPx(false),
@@ -1445,47 +1490,22 @@ function ListView({
);
return (
<div
- className="files-page-list files-page-list--adaptive"
+ className={`files-page-list files-page-list--adaptive${touchSelecting ? " files-page-list--selection-column" : ""}`}
role="grid"
ref={setContainer}
>
<div className="files-page-list-row is-header" role="row">
- {onSetSelection && visibleCount > 0 ? (
- <span role="columnheader">
- <Checkbox
- checked={allSelected}
- indeterminate={someSelected}
- disabled={picker?.selectionDisabled}
- onChange={(event) => {
- // A click clears the native mixed state even when the pick limit prevents a selection change.
- event.currentTarget.indeterminate = someSelected;
- if (picker) {
- const next = new Set(selectedFileIds);
- for (const id of visibleFileIds) {
- if (allSelected) next.delete(id);
- else next.add(id);
- }
- onSetSelection(next);
- picker.onSetDiskSelection(
- allSelected ? [] : visibleDiskFiles,
- );
- } else {
- onSetSelection(
- allSelected ? new Set() : new Set(visibleFileIds),
- );
- }
- }}
- aria-label={
- allSelected
- ? t("filesPage.deselectAll", "Clear selection")
- : t("filesPage.selectAll", "Select all")
- }
- />
- </span>
- ) : (
- <span aria-hidden="true" />
- )}
- <span role="columnheader">
+ {selectionColumn &&
+ (selectAll ? (
+ <span role="columnheader">{selectAll}</span>
+ ) : (
+ <span aria-hidden="true" />
+ ))}
+ <span role="columnheader" className="files-page-list-name-header">
+ {/* The thumbnail's slot, so the checkbox sits over the file icons and Name over the file names. */}
+ {!selectionColumn && (
+ <span className="files-page-list-thumb">{selectAll}</span>
+ )}
<span {...headerProps("name-asc", "name-desc")}>
{t("filesPage.column.name", "Name")}
{sortIndicator("name-asc", "name-desc")}
@@ -1533,6 +1553,7 @@ function ListView({
<FolderRow
key={`folder-${entry.folder.id}`}
selectionOnly={Boolean(picker)}
+ selectionColumn={selectionColumn}
folder={entry.folder}
fileCount={entry.folderFileCount ?? 0}
parentPath={entry.parentPath}
@@ -1547,6 +1568,7 @@ function ListView({
<DiskFileRow
key={`disk-${entry.disk.path}`}
selectionOnly={Boolean(picker)}
+ selectionColumn={selectionColumn}
isSelected={picker?.selectedDiskPaths.has(entry.disk.path)}
disabledReason={picker?.disabledReason(entry)}
entry={entry.disk}
@@ -1573,11 +1595,7 @@ function ListView({
isInWorkspace={
activeWorkspaceFileIds?.has(entry.file.id) ?? false
}
- multiSelectActive={
- !picker?.foldersOnly &&
- (Boolean(picker) ||
- selectedFileIds.size >= (touchSelection ? 1 : 2))
- }
+ selectionColumn={selectionColumn}
touchSelection={touchSelection}
downloadAvailable={Boolean(onDownloadFile)}
renameAvailable={Boolean(onRenameFile)}
@@ -1605,6 +1623,7 @@ function ListView({
const FolderRow = React.memo(function FolderRow({
selectionOnly,
+ selectionColumn,
folder,
fileCount,
parentPath,
@@ -1694,7 +1713,7 @@ const FolderRow = React.memo(function FolderRow({
}}
className={`files-page-list-row${isDropTarget ? " is-drop-target" : ""}`}
>
- <span aria-hidden="true" />
+ {selectionColumn && <span aria-hidden="true" />}
<span
role="gridcell"
@@ -1831,7 +1850,7 @@ interface FileRowProps {
isInWorkspace: boolean;
parentPath?: string;
- multiSelectActive: boolean;
+ selectionColumn: boolean;
touchSelection: boolean;
downloadAvailable: boolean;
@@ -1859,7 +1878,7 @@ const FileRow = React.memo(function FileRow({
isSelected,
isInWorkspace,
parentPath,
- multiSelectActive,
+ selectionColumn,
touchSelection,
downloadAvailable,
renameAvailable,
@@ -1927,26 +1946,27 @@ const FileRow = React.memo(function FileRow({
className={`files-page-list-row${isSelected ? " is-selected" : ""}${isInWorkspace ? " is-in-workspace" : ""}${locked ? " is-locked" : ""}`}
title={disabledReason ?? (locked ? lockedHint : undefined)}
>
- {multiSelectActive ? (
- <span role="gridcell">
- <Checkbox
- disabled={Boolean(disabledReason)}
- checked={isSelected}
- onClick={(e) => {
- e.stopPropagation();
- actions.selectFile(file.id, false, true);
- }}
- onChange={() => {
- /* handled by onClick */
- }}
- aria-label={t("filesPage.selectFile", "Select file {{name}}", {
- name: file.name,
- })}
- />
- </span>
- ) : (
- <span aria-hidden="true" />
- )}
+ {selectionColumn &&
+ (folderPicker ? (
+ <span aria-hidden="true" />
+ ) : (
+ <span role="gridcell">
+ <Checkbox
+ disabled={Boolean(disabledReason)}
+ checked={isSelected}
+ onClick={(e) => {
+ e.stopPropagation();
+ actions.selectFile(file.id, false, true);
+ }}
+ onChange={() => {
+ /* handled by onClick */
+ }}
+ aria-label={t("filesPage.selectFile", "Select file {{name}}", {
+ name: file.name,
+ })}
+ />
+ </span>
+ ))}
<span
role="gridcell"
style={{
@@ -2212,6 +2232,7 @@ const DiskFileCard = React.memo(function DiskFileCard({
const DiskFileRow = React.memo(function DiskFileRow({
selectionOnly,
+ selectionColumn,
isSelected,
disabledReason,
entry,
@@ -2221,6 +2242,7 @@ const DiskFileRow = React.memo(function DiskFileRow({
actions,
}: {
selectionOnly?: boolean;
+ selectionColumn: boolean;
isSelected?: boolean;
disabledReason?: string;
entry: DiskFileEntry;
@@ -2259,22 +2281,24 @@ const DiskFileRow = React.memo(function DiskFileRow({
}}
title={disabledReason ?? (processingLocked ? lockedHint : entry.path)}
>
- <span role="gridcell">
- {selectionOnly && (
- <Checkbox
- checked={Boolean(isSelected)}
- disabled={locked}
- onClick={(event) => {
- event.stopPropagation();
- actions.selectDiskFile(entry, event.shiftKey);
- }}
- onChange={() => {}}
- aria-label={t("filesPage.selectFile", "Select file {{name}}", {
- name: entry.name,
- })}
- />
- )}
- </span>
+ {selectionColumn && (
+ <span role="gridcell">
+ {selectionOnly && (
+ <Checkbox
+ checked={Boolean(isSelected)}
+ disabled={locked}
+ onClick={(event) => {
+ event.stopPropagation();
+ actions.selectDiskFile(entry, event.shiftKey);
+ }}
+ onChange={() => {}}
+ aria-label={t("filesPage.selectFile", "Select file {{name}}", {
+ name: entry.name,
+ })}
+ />
+ )}
+ </span>
+ )}
<span
role="gridcell"
style={{
diff --git a/frontend/editor/src/core/components/filesPage/FilesPage.css b/frontend/editor/src/core/components/filesPage/FilesPage.css
index 5156762ba2..84a0c8358a 100644
--- a/frontend/editor/src/core/components/filesPage/FilesPage.css
+++ b/frontend/editor/src/core/components/filesPage/FilesPage.css
@@ -284,11 +284,11 @@
.files-page-list-row {
display: grid;
/* Keep fixed column floors across independent row grids; intrinsic widths misalign rows. */
- grid-template-columns:
- 2.25rem minmax(17rem, 3fr) minmax(7.5rem, 1fr) minmax(4.5rem, 1fr)
- minmax(9.5rem, 1.5fr) minmax(8rem, 11rem) 2.5rem;
+ --files-page-list-columns: minmax(17rem, 3fr) minmax(7.5rem, 1fr)
+ minmax(4.5rem, 1fr) minmax(9.5rem, 1.5fr) minmax(8rem, 11rem) 2.5rem;
+ grid-template-columns: var(--files-page-list-columns);
/* Match the column floors so the list owns horizontal overflow. */
- min-width: 56rem;
+ min-width: 53.25rem;
gap: 0.5rem;
align-items: center;
@@ -301,6 +301,11 @@
transition: background-color 0.12s ease;
}
+.files-page-list--selection-column .files-page-list-row {
+ grid-template-columns: 2.25rem var(--files-page-list-columns);
+ min-width: 56rem;
+}
+
.files-page-list-row:last-child {
border-bottom: none;
}
@@ -320,6 +325,12 @@
min-height: 3rem;
}
+.files-page-list-name-header {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+}
+
.files-page-list-row.is-header [data-sortable="true"] {
display: block;
cursor: pointer;
@@ -336,11 +347,14 @@
color: var(--c-text);
}
-.files-page-list-row:not(.is-header):hover,
-.files-page-list-row.is-selected {
+.files-page-list-row:not(.is-header, .is-selected):hover {
background: var(--c-hover);
}
+.files-page-list-row.is-selected {
+ background: var(--c-primary-subtle);
+}
+
.files-page-list-row.is-drop-target {
background: color-mix(in srgb, var(--c-primary) 12%, transparent);
box-shadow: inset 0 0 0 1px var(--c-primary);
@@ -851,7 +865,7 @@
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
-.files-page-list-row.is-in-workspace {
+.files-page-list-row.is-in-workspace:not(.is-selected) {
background: color-mix(
in srgb,
var(--mantine-color-teal-6, var(--c-success)) 4%,
@@ -1556,18 +1570,15 @@
@container files-list (max-width: 40rem) {
.files-page-list-row {
- grid-template-columns: 0 minmax(0, 1fr) auto 2.5rem;
+ grid-template-columns: minmax(0, 1fr) auto 2.5rem;
min-width: 0;
min-height: 3.25rem;
- padding: 0.35rem 0.25rem;
+ padding: 0.35rem 0.25rem 0.35rem 0.75rem;
}
- :where(
- .files-page-list--adaptive:has(
- .files-page-list-row:not(.is-header) .mantine-Checkbox-root
- )
- )
- .files-page-list-row {
+ .files-page-list--selection-column .files-page-list-row {
grid-template-columns: 2rem minmax(0, 1fr) auto 2.5rem;
+ min-width: 0;
+ padding-left: 0.25rem;
}
.files-page-list-row > :first-child {
overflow: hidden;
diff --git a/frontend/editor/src/core/components/filesPage/LibraryFilePicker.css b/frontend/editor/src/core/components/filesPage/LibraryFilePicker.css
index b6cdff69e4..f5670437d6 100644
--- a/frontend/editor/src/core/components/filesPage/LibraryFilePicker.css
+++ b/frontend/editor/src/core/components/filesPage/LibraryFilePicker.css
@@ -59,6 +59,7 @@
.library-file-picker .files-page-list-row {
grid-template-columns: 0 minmax(0, 1fr) 2.5rem;
min-width: 0;
+ padding-left: 0.25rem;
}
.library-file-picker
.files-page-list--adaptive:has(
diff --git a/frontend/editor/src/core/tests/stubbed/files-page.spec.ts b/frontend/editor/src/core/tests/stubbed/files-page.spec.ts
index f2ea6b54cd..d8c3050f3f 100644
--- a/frontend/editor/src/core/tests/stubbed/files-page.spec.ts
+++ b/frontend/editor/src/core/tests/stubbed/files-page.spec.ts
@@ -245,23 +245,13 @@ test.describe("Files page", () => {
await expect(page.locator(".files-page-card.is-selected")).toHaveCount(2);
});
- test("checkboxes hidden in single-select, visible in multi-select", async ({
- page,
- }) => {
+ test("selection highlights cards without checkboxes", async ({ page }) => {
await gotoFilesPage(page);
const cards = page.locator(".files-page-card:not(.is-folder)");
- // 0 selected: no checkboxes anywhere on file cards.
- await expect(page.locator(".files-page-card-selector")).toHaveCount(0);
-
- // 1 selected: still no checkbox (highlight border is the indicator).
await cards.nth(0).click();
- await expect(page.locator(".files-page-card-selector")).toHaveCount(0);
-
- // 2+ selected: checkboxes appear on every file card.
await cards.nth(1).click({ modifiers: ["ControlOrMeta"] });
- await expect(
- page.locator(".files-page-card-selector").first(),
- ).toBeVisible();
+ await expect(page.locator(".files-page-card.is-selected")).toHaveCount(2);
+ await expect(page.locator(".files-page-card-selector")).toHaveCount(0);
});
});