Skip to content

Add support for fixed column widths#23

Merged
texodus merged 1 commit intofinos:masterfrom
patricio-mancini:fixed-max-width-for-columns-feature
Jun 8, 2020
Merged

Add support for fixed column widths#23
texodus merged 1 commit intofinos:masterfrom
patricio-mancini:fixed-max-width-for-columns-feature

Conversation

@patricio-mancini
Copy link
Copy Markdown
Contributor

@patricio-mancini patricio-mancini commented May 29, 2020

This pull request adds support for fixed column widths by applying custom attributes maxWidth and minWidth to the cells of the <regular-table/> ensuring that the columns don’t grow or shrink past the attributes’ limits. Adds a new example:

  • This contribution includes fixed_column_width.html, an example use of the fixed column width feature allowing developers to explore and extend its implementation.

Copy link
Copy Markdown
Member

@texodus texodus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I think the work so far here demonstrates we can't make a real improvement to this feature without first implementing good underlying abstractions for "user-draggable column resizing" (e.g. overrides) and "auto-detected column minimum widths" (e.g. auto), as 'fixed column widths' conflates both of these topics as well as "HTML layout generated widths" (e.g. offsetWidth). It may even be possible to use getComputedStyle() to read these bounds from the computed style rules on the element itself.

You might also try using your apply() function to set a class instead, then use a generated class and an !important directive to override the min-width and max-width generated by the auto-sizing.

Comment thread examples/fixed_column_width.html Outdated
Comment thread examples/fixed_column_width.html Outdated
Comment thread src/js/events.js Outdated
@patricio-mancini patricio-mancini force-pushed the fixed-max-width-for-columns-feature branch 2 times, most recently from 1baf5f7 to 738d697 Compare June 5, 2020 19:27
@patricio-mancini patricio-mancini force-pushed the fixed-max-width-for-columns-feature branch from 738d697 to 8e22ea4 Compare June 5, 2020 21:01
Copy link
Copy Markdown
Member

@texodus texodus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Great test coverage and great documentation as well. I left some small comments inline below that are not necessary to address.

* It is possible to manually shrink the column width up to the limit of 10 pixels.
* Column widths are calculated by the library using the max-width css rule. Which
means that settings the max-width from a css rule will lead to a fixed width
behavior for the cells of that column.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these list-item hard wraps need to be indented https://www.markdownguide.org/basic-syntax/#adding-elements-in-lists

// Set fixed min-width to cells when appropiate.
function styleListener() {
const ths = tableApi.querySelectorAll("thead th");
const tds = tableApi.querySelectorAll("tbody td");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be

const elems = tableApi.querySelectorAll("thead th, tbody td");

The DOM API is very expressive already!

/* Set fixed width for cells. */
.fixed {
min-width: 100px !important;
max-width: 100px !important;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems important - I'd put it at the top!


const baseColumns = ["Fixed", "Not Set"];
const columnCount = 20;
const cellCount = 1000;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are also CONSTANTS and belong at the top of the script

@texodus
Copy link
Copy Markdown
Member

texodus commented Jun 8, 2020

Thanks for the PR!

@texodus texodus merged commit 36dc13c into finos:master Jun 8, 2020
texodus added a commit that referenced this pull request Jun 8, 2020
texodus added a commit that referenced this pull request Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants