glideapps / glide-data-grid

🚀 Glide Data Grid is a no compromise, outrageously react fast data grid with rich rendering, first class accessibility, and full TypeScript support.
https://grid.glideapps.com
MIT License
3.98k stars 288 forks source link

possible bug in packages/core/src/internal/data-grid/render/data-grid-render.header.ts #947

Open A-Posthuman opened 5 months ago

A-Posthuman commented 5 months ago

I'm using the new alpha code for the header indicator icon, and also I've modified the code a bit to support right alignment (not rtl, just normal ltr but right aligned within the header cell) of the header text, and to support wrapping the text onto 2 lines.

Anyway while working on that I realized in this code at line 382 where it computes textBounds.width, the calculation was sometimes returning negative numbers, which I assume is incorrect. I modified it my version to:

width: (x + width) - drawX - xPad

That seems to generate better results.

Also the code just below there at line 392 which modifies textBounds.width in the case of a header indicator icon, I was sometimes seeing the new width set to too low of a number. I didn't have time to trace that all the way back to see what was happening, I changed mine to:

textBounds.width -= headerIconSize + xPad;
drawX += textBounds.width + xPad;