Skip to content

Commit 75da328

Browse files
authored
PDF Editor: Allow users to include excluded fields with another delete press (#699)
1 parent 7376951 commit 75da328

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

docs/src/content/docs/guides/new-pdfs.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Some fields, like internal bureaucratic coding, will never be filled in by a Nam
5353

5454
To exclude a field using the PDF Manager, select the field name from the list and press `Delete` or `Backspace`. Excluded fields will appear at the bottom of the list with a strikethrough. Click **Save** to write all exclusions to disk.
5555

56+
To restore an excluded field, select it from the **Excluded** list and press `Delete` or `Backspace` again. It will move back into the active field list. Click **Save** to write the restored fields to disk.
57+
5658
## Rename remaining fields
5759

5860
Once unused fields have been excluded, the remaining fields should be renamed. We rename fields to make it easier to work with PDFs, and because the default names are often undescriptive.

pdf-manager/src/components/FieldList.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export function FieldList({
211211
height: number;
212212
} | null>(null);
213213
const listRef = useRef<HTMLDivElement>(null);
214+
const excludedListRef = useRef<HTMLDivElement>(null);
214215
const scrollAreaRef = useRef<HTMLDivElement>(null);
215216

216217
const focusList = () => setTimeout(() => listRef.current?.focus(), 0);
@@ -250,7 +251,12 @@ export function FieldList({
250251
// Capture phase so Delete/Backspace/Enter reach us before RAC's type-ahead and activation handlers.
251252
useEffect(() => {
252253
function onKeyDown(e: KeyboardEvent) {
253-
if (!listRef.current?.contains(document.activeElement)) return;
254+
const activeElement = document.activeElement;
255+
const listHasFocus =
256+
activeElement &&
257+
(listRef.current?.contains(activeElement) ||
258+
excludedListRef.current?.contains(activeElement));
259+
if (!listHasFocus) return;
254260
if (renamingField) return;
255261
if ((e.key === "Delete" || e.key === "Backspace") && highlightedField) {
256262
e.preventDefault();
@@ -316,6 +322,7 @@ export function FieldList({
316322
<div className="field-excluded-group">
317323
<div className="field-section-label">Excluded</div>
318324
<ListBox
325+
ref={excludedListRef}
319326
aria-label="Excluded fields"
320327
className="field-list field-list-excluded"
321328
selectionMode="single"

0 commit comments

Comments
 (0)