Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix(production): drop the soft hyphens from long note words

Raul1dd6b212a540
diff --git a/apps/mes/app/components/JobOperation/components/BatchOverview.tsx b/apps/mes/app/components/JobOperation/components/BatchOverview.tsx
index 68faa73192..33716f7c2e 100644
--- a/apps/mes/app/components/JobOperation/components/BatchOverview.tsx
+++ b/apps/mes/app/components/JobOperation/components/BatchOverview.tsx
@@ -157,6 +157,7 @@ export function BatchOverview({
// steps on Instructions, and before the load list on Details, the tab the
// batch opens on, so an operator who loads and starts from Details reads them.
const notes = batch.notes?.trim() ? batch.notes : null;
+ /** The notes as a section of this tab, or nothing when there are none. */
const notesSection = (divider: boolean) =>
notes && (
<Section divider={divider} title={t`Batch notes`}>
diff --git a/packages/documents/src/pdf/BatchListPDF.test.ts b/packages/documents/src/pdf/BatchListPDF.test.ts
index 8dd8ea2e68..352c474497 100644
--- a/packages/documents/src/pdf/BatchListPDF.test.ts
+++ b/packages/documents/src/pdf/BatchListPDF.test.ts
@@ -55,16 +55,11 @@ describe("breakLongNotesWord", () => {
expect(breakLongNotesWord("x".repeat(40))).toEqual(["x".repeat(40)]);
});
- it("lets a longer word break every 40 characters, at a soft hyphen", () => {
+ it("lets a longer word break every 40 characters", () => {
const url = `https://example.com/${"a".repeat(80)}`;
const parts = breakLongNotesWord(url);
- const pieces = parts.map((part) => part.replace("\u00AD", ""));
- expect(pieces.join("")).toBe(url);
- expect(pieces.every((piece) => piece.length <= 40)).toBe(true);
+ expect(parts.join("")).toBe(url);
+ expect(parts.every((part) => part.length <= 40)).toBe(true);
expect(parts).toHaveLength(3);
- expect(parts.slice(0, -1).every((part) => part.endsWith("\u00AD"))).toBe(
- true
- );
- expect(parts.at(-1)).not.toContain("\u00AD");
});
});
diff --git a/packages/documents/src/pdf/notesText.ts b/packages/documents/src/pdf/notesText.ts
index 1c54b3d2c3..2e8f670317 100644
--- a/packages/documents/src/pdf/notesText.ts
+++ b/packages/documents/src/pdf/notesText.ts
@@ -5,19 +5,17 @@
// react-pdf breaks a line only between words or at the English hyphenation
// points it finds, so an unbroken string wider than the page (a URL, a file
// path) printed past the margin. Plain-text notes break at spaces, and a
-// longer word every NOTES_WORD_CHUNK characters. Each piece but the last ends
-// in a soft hyphen, the usual mark for a place a word may break.
+// longer word every NOTES_WORD_CHUNK characters. Textkit draws the hyphen at
+// the break. No soft hyphen in the pieces: each one moves the later breaks a
+// character past these boundaries, splitting "[080]" as "[0-" and "80]".
const NOTES_WORD_CHUNK = 40;
-const SOFT_HYPHEN = "\u00AD";
/** The `hyphenationCallback` for a `<Text>` of plain-text notes. */
export function breakLongNotesWord(word: string): string[] {
if (word.length <= NOTES_WORD_CHUNK) return [word];
const parts: string[] = [];
for (let start = 0; start < word.length; start += NOTES_WORD_CHUNK) {
- const end = Math.min(start + NOTES_WORD_CHUNK, word.length);
- const part = word.slice(start, end);
- parts.push(end < word.length ? `${part}${SOFT_HYPHEN}` : part);
+ parts.push(word.slice(start, start + NOTES_WORD_CHUNK));
}
return parts;
}