Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
fix(tags): render selected chips in pick order so resume skills match the view and PDF export
Khuram Niazf6165dcee195
diff --git a/__tests__/TagInput.spec.tsx b/__tests__/TagInput.spec.tsxindex 6179387..97b5891 100644--- a/__tests__/TagInput.spec.tsx+++ b/__tests__/TagInput.spec.tsx@@ -71,6 +71,13 @@ const MOCK_TAGS: Tag[] = [{ id: "tag-3", label: "Node.js", value: "node.js", createdBy: "user-1" },];+// Badge labels in render order, read off each chip's remove button.+function selectedLabels(): string[] {+ return screen+ .getAllByRole("button", { name: /^Remove / })+ .map((btn) => btn.getAttribute("aria-label")!.replace(/^Remove /, ""));+}+describe("TagInput Component", () => {const user = userEvent.setup({ skipHover: true });@@ -165,6 +172,38 @@ describe("TagInput Component", () => {});});+ it("orders badges by selection order, not the available-tag pool order", async () => {+ // getAllTags returns the pool sorted by label, so deriving the chips from+ // the pool made them render alphabetically while the saved Skill.order+ // followed the click order.+ render(<ControlledTagInput availableTags={MOCK_TAGS} />);++ await user.click(screen.getByRole("combobox"));+ await user.click(await screen.findByRole("option", { name: "TypeScript" }));++ await user.click(screen.getByRole("combobox"));+ await user.click(await screen.findByRole("option", { name: "React" }));++ await waitFor(() => {+ expect(selectedLabels()).toEqual(["TypeScript", "React"]);+ });+ });++ it("renders pre-selected badges in the given id order", async () => {+ // The skills edit dialog passes tagIds sorted by Skill.order, so the chips+ // must mirror what the resume view and PDF export show.+ render(+ <ControlledTagInput+ availableTags={MOCK_TAGS}+ initialIds={["tag-3", "tag-1", "tag-2"]}+ />,+ );++ await waitFor(() => {+ expect(selectedLabels()).toEqual(["Node.js", "React", "TypeScript"]);+ });+ });+it("renders chips for pre-selected tags that load after mount", async () => {// Reproduces the import-edit bug: the picker mounts before its tag pool is// fetched. Chips must appear once availableTags arrives via a prop update.diff --git a/src/components/myjobs/TagInput.tsx b/src/components/myjobs/TagInput.tsxindex 409cefd..7b7c33e 100644--- a/src/components/myjobs/TagInput.tsx+++ b/src/components/myjobs/TagInput.tsx@@ -60,7 +60,13 @@ export function TagInput({});}, [availableTags]);- const selectedTags = localTags.filter((t) => selectedTagIds.includes(t.id));+ // Map over the ids, not the pool: the pool arrives sorted by label, so+ // filtering it would render chips alphabetically instead of in the order the+ // user picked them — the order callers persist and render.+ const tagsById = new Map(localTags.map((t) => [t.id, t]));+ const selectedTags = selectedTagIds+ .map((id) => tagsById.get(id))+ .filter((t): t is Tag => !!t);const isMaxReached = selectedTagIds.length >= max;// Tags not yet selected, filtered by input