How the More actions menu is built
The app bar on /build had grown to five controls: Start over, Import from LinkedIn (when it is turned on), Export JSON, Preview, and a Download PDF button inside the preview. Now there is one labelled button, Preview, and a More actions menu behind the three-dot icon next to it.
This post covers what is in the menu, why the dialogs sit outside it, how Download PDF works now that the menu and the preview share it, and what did not change.
What you will notice
- The app bar shows Preview and a three-dot More actions button.
- The menu holds, in this order: Download PDF, Export JSON, Import from LinkedIn (only when the feature flag is on), a divider, and Start over in red.
- Download PDF and Export JSON stay greyed out until the resume has a name. Preview works the same way.
- While a PDF builds, the item reads "Preparing PDF…". The menu closes when the file is ready.
- If the PDF cannot be built, you get a snackbar: "Could not download this PDF."
- Download PDF is still in the preview dialog too, with a spinner while it works.
Export JSON, Start over and autosave behave as before. The PDF looks the same.
Where the pieces live
| Piece | Path | Role |
|---|---|---|
| Menu | src/components/build/BuildMenu.tsx |
The trigger, the menu items, and the dialogs and snackbars that sit beside it. |
| App bar | src/components/forms/Form.tsx |
Preview button, BuildMenu, and one usePdfDownload() call shared with the preview. |
| Download hook | src/components/build/hooks/usePdfDownload.ts |
Busy state, double-click guard, error notice. |
| Download function | src/lib/pdf/downloadResumePdf.ts |
Builds the PDF blob and triggers the download. |
| PDF document | src/components/pdf/ResumePdfDocument.tsx |
The react-pdf document tree, moved out of the old PdfDownload component. |
src/components/build/LinkedInImportDialogs.tsx |
startLinkedInImport for the menu item, LinkedInImportDialogs for the review dialog and the restore effect. |
|
| Notices | src/components/build/Notices.tsx |
Autosave warning, export notice, and the new PDF error snackbar. |
The menu
The trigger is an MUI IconButton with the MoreVert icon. It has no visible text, so the label is in aria-label:
// src/components/build/BuildMenu.tsx
<IconButton
aria-label="More actions"
aria-controls={open ? "build-actions-menu" : undefined}
aria-haspopup="true"
aria-expanded={open ? "true" : undefined}
color="inherit"
size="small"
onClick={(event) => setAnchorEl(event.currentTarget)}
>
<MoreVert />
</IconButton>
The menu is an MUI Menu anchored to that button, opening below it and aligned to the right edge. Each item is a MenuItem. Two rules decide what is clickable:
hasNamecomes frompersonalDetailsHasValue(values.personalDetails). Download PDF and Export JSON are disabled without it, the same rule Preview already used.- Download PDF is also disabled while a PDF is building.
Start over is always enabled. Its red comes from sx={{ color: "error.main" }}. The colour is a hint. The label and the confirm dialog that follows carry the meaning.
Why the dialogs live outside the menu
MUI's Menu unmounts its children when it closes. Each item closes the menu when you click it. If the Start over dialog were rendered inside the menu, it would be removed in the same click that should open it.
So BuildMenu renders the menu and, next to it, the things that must outlive it:
// src/components/build/BuildMenu.tsx
<StartOverDialog
open={startOver.isOpen}
onCancel={startOver.cancel}
onConfirm={startOver.confirm}
/>
{linkedInEnabled ? <LinkedInImportDialogs /> : null}
<Notices
autosaveWarning={autosaveWarning}
exportNotice={{ notice, clearNotice }}
pdfNotice={{
notice: pdfDownload.notice,
clearNotice: pdfDownload.clearNotice,
}}
/>
The Start over item calls close() and then startOver.request(). The menu goes away and the dialog opens, because the dialog was never inside it.
One PDF download path
Before, the PDF button was a PdfDownload component in the preview dialog. It wrapped react-pdf's PDFDownloadLink and kept the document element in a useMemo on the four resume slices. That worked in one place. With a second Download PDF in the menu, there would have been two components building PDFs on their own.
Now there is one function and one hook.
The document tree moved into ResumePdfDocument, which takes the whole editor document:
// src/components/pdf/ResumePdfDocument.tsx
export function ResumePdfDocument({ values }: { values: EditorFormValues }) {
const { personalDetails, contactDetails, experienceItems, educationItems } =
values;
return (
<Document>
<PageWithStyle>
<PersonalAndContactDetails
personalDetails={personalDetails}
contactDetails={contactDetails || {}}
/>
{experienceItemsHasValues(experienceItems) && (
<Experience experience={experienceItems || []} />
)}
{educationItemsHasValues(educationItems) && (
<Education educationItems={educationItems || []} />
)}
</PageWithStyle>
</Document>
);
}
The sections, the conditions and the Roboto font registration are the same as in the deleted component, so the PDF layout did not change.
downloadResumePdf builds the file and starts the download:
// src/lib/pdf/downloadResumePdf.ts
export async function downloadResumePdf(values: EditorFormValues): Promise<void> {
const documentElement = createElement(ResumePdfDocument, {
values,
}) as ReactElement<DocumentProps>;
const blob = await pdf(documentElement).toBlob();
const url = URL.createObjectURL(blob);
const anchor = document.createElement("a");
anchor.href = url;
anchor.download = pdfFileName(values);
anchor.rel = "noopener";
document.body.appendChild(anchor);
anchor.click();
anchor.remove();
window.setTimeout(() => URL.revokeObjectURL(url), 1000);
}
It is a .ts file, so it uses createElement instead of JSX. The object URL is revoked a second after the click.
The filename is unchanged: Resume_ plus the name with spaces replaced by underscores. Like the old link, the download attribute has no .pdf at the end. Chrome adds .pdf from the file type. Other browsers have not been checked.
The PDF is now built only when you click, from a snapshot of the document at that moment (useResumeSnapshot). Nothing is built while you edit.
Busy state and double clicks
usePdfDownload wraps the function:
// src/components/build/hooks/usePdfDownload.ts
const download = useCallback(() => {
if (inFlight.current) return;
inFlight.current = true;
setBusy(true);
setNotice(null);
void downloadResumePdf(getSnapshot())
.catch(() => {
setNotice({ severity: "error", message: "Could not download this PDF." });
})
.finally(() => {
inFlight.current = false;
setBusy(false);
});
}, [getSnapshot]);
The inFlight ref is the double-click guard. A ref changes at once, while busy only reaches the button on the next render, so a fast second click still sees the first one in flight and returns.
Form.tsx calls usePdfDownload() once and passes the result to both BuildMenu and PreviewDialog. They share the busy state and the error notice. Starting a download from one disables the button in the other.
In the menu, Download PDF does not close the menu right away. It sets a closeAfterPdf ref, and an effect closes the menu when busy goes back to false. You see "Preparing PDF…" in the menu, then the menu closes. If the build fails, the snackbar stays up after the menu closes, because Notices is outside the menu.
Import from LinkedIn
The old LinkedInImport component was a button plus its dialogs and the restore effect. The button had to become a menu item, and the dialogs had to stay mounted when the menu closed, so the file is now split in two:
startLinkedInImport(getSnapshot)saves the editor tosessionStorageand sends the browser to the LinkedIn sign-in route. The menu item calls it.LinkedInImportDialogsholds the review dialog, its snackbar and the restore effect, rendered beside the menu.
Both only exist when NEXT_PUBLIC_FEATURE_LINKEDIN_IMPORT is exactly "true". It is off by default, so most people will not see the item. The restore is still a passive effect, so it still runs after the autosave load and still wins on the way back from LinkedIn.
Keyboard and screen readers
The menu adds no keyboard code of its own. It relies on MUI's Menu, which moves focus into the list when it opens, lets you move between items with the arrow keys, and closes on Escape. What the code adds is the ARIA wiring on the trigger shown above, and aria-busy on both Download PDF controls while a file builds. No automated keyboard or screen-reader test covers this yet.
What did not change
- Autosave timing and storage.
- The Export JSON file format and its success notice.
- The PDF layout and filename.
- The Start over dialog and what it clears.
- No new dependencies.
How it was checked
The repo still has no automated test suite. The checks were lint, a production build, and a scripted browser run against that build: the PDF text matched the form and preview, a double click on either control gave one download, both busy labels appeared, and a temporary forced failure (not committed) showed the snackbar with no download.
You can try it in the editor at https://resumer.orlinivanov.com/build. Add your name, open the three-dot menu, and download the PDF.