react-data-grid icon indicating copy to clipboard operation
react-data-grid copied to clipboard

Column auto size not working on Firefox

Open holospice18 opened this issue 2 years ago • 3 comments

Describe the bug

Auto size on Firefox does not work unless 'size' is defined

On Chrome column size is defined by cell content On Firefox column size is defined by Grid

Chrome image

Firefox image

holospice18 avatar Dec 22 '23 08:12 holospice18

react-data-grid uses auto as the default width. This looks like a bug in FF and not in react-data-grid.

amanmahajan7 avatar Jan 02 '24 18:01 amanmahajan7

@amanmahajan7 even if it is a browser bug, any ideas how to work around this? We're currently witnessing the same behavior. I've tried setting min-width: fit-content on the gridcell and column header and that actually seems to fix things on safari and firefox, but then it breaks on chrome.

Update: Seemingly got this to work by setting min-width: min-content; on gridcell and columheader:

{
  [role='gridcell'] {
    min-width: min-content;
  }
  [role='columnheader'] {
    min-width: min-content;
  }
}

YMMV - I haven't tested this throughly, and it likely has the effect of disallowing a column from ever overflowing, which maybe won't work for all use cases. But for our specific use case of requiring that cell content never overflows it seems to work.

jcharry avatar Feb 16 '24 15:02 jcharry

You can try using <DataGrid defaultColumnOptions={{ width: ''max-content' }} ...

amanmahajan7 avatar Feb 21 '24 12:02 amanmahajan7

Closing due to inactivity

amanmahajan7 avatar Nov 25 '24 01:11 amanmahajan7