[Bug Report]: getBytesLength counts every character as uppercase when a word has one capital, and snapToGrid never snaps to 0
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, typescript
- Ambito
- frontend
Direzione di ricerca
Due piccoli bug in packages/core: il ciclo getBytesLength in src/util/edge.ts (~L809) verifica word.match(/[A-Z]/) mentre dovrebbe verificare il carattere corrente c, e snapToGrid in src/util/geometry.ts (~L9) usa || point, che restituisce erroneamente il valore grezzo quando il risultato allineato è 0. Controlla anche la guardia if (nodeX && nodeY) in GraphModel.ts all'interno di getModelAfterSnapToGrid. Inizia eseguendo lo script di riproduzione dell'issue. Il lavoro è completato quando si ottengono gli output attesi elencati lì ([0, 0, 10, 10], lunghezze in byte 7.5 e 17.5) e i test esistenti delle utility continuano a passare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happened?
Two utility bugs in @logicflow/core affect default text sizing and grid snapping:
-
getBytesLengthchecks the whole string instead of the current character. Inpackages/core/src/util/edge.ts#L809, the loop readsconst c = word.charCodeAt(i)but testsif (word.match(/[A-Z]/)), so a single capital letter gives every character inwordweight1.5.getSvgTextSize(edge label background<rect>inLineText) andgetSvgTextWidthHeight(TextNodeModel.width) both call it:- Lowercase ASCII characters (weight
1) count as1.5, making'Approve'50% wider than'approve'(75vs51atfontSize: 12). - CJK characters (weight
2) also drop to1.5, so prepending'A'to'网关审批流程节点'shrinks the computed width from99to87and the text overflows its box.
- Lowercase ASCII characters (weight
-
snapToGridskips0. Inpackages/core/src/util/geometry.ts#L9,gridSize * Math.round(point / gridSize) || pointfalls back topointwhenever the snapped coordinate is0(|point| < gridSize / 2). WhensnapGrid: true, nodes dragged, dropped, or added nearx = 0ory = 0keep their raw coordinate instead of snapping to0(andgetModelAfterSnapToGridinGraphModel.tsalso guards withif (nodeX && nodeY), skipping both axes when either coordinate is0).
Reproduction (npm i @logicflow/[email protected] && node repro.js, Node v26.13.0):
const {
snapToGrid,
getBytesLength,
getSvgTextSize,
getSvgTextWidthHeight,
} = require("@logicflow/core");
console.log([4, -4, 6, 14].map((v) => snapToGrid(v, 10, true)));
console.log(getBytesLength("approve"), getBytesLength("Approve"));
console.log(
getSvgTextSize({ rows: ["approve"], rowsLength: 1, fontSize: 12 }).width,
getSvgTextSize({ rows: ["Approve"], rowsLength: 1, fontSize: 12 }).width,
);
console.log(getBytesLength("网关审批流程节点"), getBytesLength("A网关审批流程节点"));
console.log(
getSvgTextWidthHeight({ rows: ["网关审批流程节点"], rowsLength: 1, fontSize: 12 }).width,
getSvgTextWidthHeight({ rows: ["A网关审批流程节点"], rowsLength: 1, fontSize: 12 }).width,
);
Actual output:
[ 4, -4, 10, 10 ]
7 10.5
51 75
16 13.5
99 87
Expected output:
snapToGridsnaps4and-4to0([ 0, 0, 10, 10 ]).getBytesLengthtests characteri(c >= 0x41 && c <= 0x5a), giving7.5for"Approve"(width51) and17.5for"A网关审批流程节点"(width111).
Core Version
2.2.5 (also verified on master d60a216)
Extension Version
2.3.1 (not required to reproduce)
Engine Version
No response
What browsers are you seeing the problem on?
Chrome
Credit: https://ucsbplse.github.io/
- Lingua principale
- TypeScript
- Stelle
- 11.8k
- Fork
- 1.4k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di didi/LogicFlow
-
[Bug Report]: resize改变画布尺寸未完全生效Forse già presa @dvd233 l’ha presa 70 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
[Bug Report]: Cannot access '{default export}' before initializationForse già presa @dvd233 l’ha presa 42 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 54/100
-
[Bug Report]: 框选引用冲突Uncaught TypeError: dynamicGroup_1.getGroupByNodeId is not a functionForse di nuovo libera @Wang-Yi-Teng l’ha presa 117 giorni fa e non c’è nessuna pull request aperta. Aperta
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
-
[Bug Report]: 收缩动态组后,控件还在外面。Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
Tutte le issue di didi/LogicFlow
Issue simili
-
bug done
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
neavo/LinguaGacha#1124 ·
I maintainer di solito rispondono entro 1 giorno
-
[fullsend] E2E: backstage-microsoft-auth — catalogQuery missing error handler for network errorsForse già presa @fullsend-ai-coder l’ha presa oggi. Apertae2e-failure ready-to-code
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 78/100
redhat-developer/rhdh-plugin-export-overlays#4821 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
brylie/mission-island#225 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement from-app needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
nightly-labs/openbot#14986 ·
I maintainer di solito rispondono entro 1 giorno
-
status/need-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
google-gemini/gemini-cli#30412 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno