| β¦ | β¦ | @@ -1,19 +1,39 @@ | |
| 27 | + | const measureBox = (box: HTMLDivElement) => { | |
| 28 | + | setWidth(box.clientWidth); | |
| 29 | + | return observeResize(box, ([entry]) => { | |
| 30 | + | if (entry) setWidth(entry.contentRect.width); | |
π‘ Medium chat/HtmlRenderDialog.tsx:30
At fractional card widths, the dialog repeatedly re-renders while idle because each contentRect.width update replaces measureBox, whose setup writes the integer clientWidth and restarts the observer; the observer's initial notification then repeats the cycle. Round the observed width to match clientWidth so the initial notification does not trigger another render.
| 1 | if (entry) setWidth(Math.round(entry.contentRect.width)); |
π€ Copy this AI Prompt to have your agent fix this:
| 1 | In file @apps/web/src/components/chat/HtmlRenderDialog.tsx around line 30: |
| 2 | |
| 3 | At fractional card widths, the dialog repeatedly re-renders while idle because each `contentRect.width` update replaces `measureBox`, whose setup writes the integer `clientWidth` and restarts the observer; the observer's initial notification then repeats the cycle. Round the observed width to match `clientWidth` so the initial notification does not trigger another render. |