From b8a1bf63999452e705976b0b672a80973a52d4ce Mon Sep 17 00:00:00 2001 From: u8array Date: Tue, 5 May 2026 22:50:23 +0200 Subject: [PATCH 1/2] fix: hide HRI checkbox and rendering for symbologies without ZPL HRI support --- src/components/Canvas/BarcodeObject.tsx | 14 ++++++++------ src/registry/barcode1d.tsx | 25 +++++++++++++++---------- src/registry/gs1databar.tsx | 2 ++ src/types/ObjectType.ts | 7 +++++++ 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/components/Canvas/BarcodeObject.tsx b/src/components/Canvas/BarcodeObject.tsx index 470ff060..4864c430 100644 --- a/src/components/Canvas/BarcodeObject.tsx +++ b/src/components/Canvas/BarcodeObject.tsx @@ -3,7 +3,7 @@ import bwipjs from "bwip-js/browser"; import { Image as KImage, Group, Rect, Text } from "react-konva"; import type Konva from "konva"; import type { LabelObject } from "../../registry"; -import { BARCODE_1D_TYPES } from "../../registry"; +import { BARCODE_1D_TYPES, ObjectRegistry } from "../../registry"; import type { ObjectChanges } from "../../store/labelStore"; import { dotsToPx, pxToDots } from "../../lib/coordinates"; import { @@ -144,8 +144,12 @@ export function BarcodeObject({ if (barcodeCanvas) { const w = displayW; const h = displayH; - const printInterp = !!(obj.props as { printInterpretation?: boolean }) - .printInterpretation; + // Force-off when the symbology has no HRI in ZPL (e.g. GS1 Databar) — the + // canvas must match the print output even if a legacy saved object still + // carries printInterpretation: true. + const printInterp = + !ObjectRegistry[obj.type]?.interpretationLocked && + !!(obj.props as { printInterpretation?: boolean }).printInterpretation; const moduleWidth = (obj.props as { moduleWidth?: number }).moduleWidth ?? 2; const textFontSize = Math.max(dotsToPx(moduleWidth * 10, scale, dpmm), 6); @@ -435,9 +439,7 @@ export function BarcodeObject({ } // ── Other 1D: separate Konva Text below bars ────────────────────────── - const showText = - BARCODE_1D_TYPES.has(obj.type) && - (obj.props as { printInterpretation?: boolean }).printInterpretation; + const showText = BARCODE_1D_TYPES.has(obj.type) && printInterp; let displayText = rawContent; if (obj.type === "code39") { diff --git a/src/registry/barcode1d.tsx b/src/registry/barcode1d.tsx index 88fa809a..8a8f24a7 100644 --- a/src/registry/barcode1d.tsx +++ b/src/registry/barcode1d.tsx @@ -32,6 +32,8 @@ interface Barcode1DConfig { byRatio?: number; /** See {@link ObjectTypeDefinition.heightLocked}. */ heightLocked?: boolean; + /** See {@link ObjectTypeDefinition.interpretationLocked}. */ + interpretationLocked?: boolean; } interface BarcodeLocale { @@ -52,11 +54,12 @@ export function createBarcode1D(config: Barcode1DConfig): ObjectTypeDefinition - + {!config.interpretationLocked && ( + + )} {config.hasCheckDigit && (