DataTablesSrc icon indicating copy to clipboard operation
DataTablesSrc copied to clipboard

should we set table.display to "table" explicitly

Open shrektan opened this issue 5 years ago • 3 comments

Related to https://github.com/rstudio/DT/issues/563

If the page contains a CSS claiming table.display to block. The whole page will display the datatable object strangely as long as the page is wider than the table.

Yes, I know adding another CSS could fix this but it frustrates the user and is difficult to debug.

Due to the fact that a datatable object could be displayed as expected, only when the table.display attribute is set to table.

So I'm proposing here that the datatable library should set this attribute by default.

The CSS that affect this issue

table {
  display: block;
}

The test case

http://live.datatables.net/novewebi/1/edit

The output

http://live.datatables.net/novewebi/1

image

shrektan avatar Mar 23 '20 15:03 shrektan

We could use table.dataTable { display: table; } but for 99% of cases it is redundant, which is why I would be mildly reluctant to put it in. It would be like putting in div { display: block } into regular html.

DataTables avatar Mar 23 '20 15:03 DataTables

It's half right, as the metaphor is not very appropriate, in my opinion.

The reason is that regular tables will still be fine with display: block. They are just compacter, as expected.

But this doesn't apply to a datatable object. The implementation of datatable library (the header, footer, and buttons) can't get along withdisplay: block and only work with display: table. In other words, it's the implementation asks for it.

shrektan avatar Mar 23 '20 15:03 shrektan

After a 2nd thought, I think this proposal may break users' existing code if they use dom: t(only the table body) with table {display: block;}, despite I doubt anyone will really do this...

So I'll leave it to you to decide if the issue should be closed or not.

Thanks!

shrektan avatar Mar 23 '20 16:03 shrektan