Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix column alignment issue when new rows were added after first render #36

Merged
merged 5 commits into from
Aug 24, 2017
Merged

Fix column alignment issue when new rows were added after first render #36

merged 5 commits into from
Aug 24, 2017

Conversation

AdamWard1995
Copy link
Contributor

@AdamWard1995 AdamWard1995 commented Aug 22, 2017

This project uses semver, please check the scope of this pr:

  • #none# - documentation fixes and/or test additions
  • #patch# - backwards-compatible bug fix
  • #minor# - adding functionality in a backwards-compatible manner
  • #major# - incompatible API change

CHANGELOG

  • Fixed column alignment issue when new rows were added after first render

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling bc5dca9 on AdamWard1995:flexTable into ** on ciena-frost:master**.

@AdamWard1995 AdamWard1995 changed the title Flex table Fix column alignment issue when new rows were added after first render Aug 23, 2017
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 3756eb0 on AdamWard1995:flexTable into ** on ciena-frost:master**.

* @returns {String} jQuery selector string for getting the header column row
*/
headerColumnsSelector (haveCategories) {
return `${haveCategories ? '.frost-table-header-columns' : ''}`
Copy link
Contributor

Choose a reason for hiding this comment

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

Why isn't this code just return haveCategories ? '.frost-table-header-columns' : ''?

this.$().css({
'flex-grow': 1,
'flex-shrink': 0,
'flex-basis': `${this.setMinimumCellWidths('')}px`
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the '' need to be passed? Can't is just be${this.setMinimumCellWidths()}px?

@notmessenger
Copy link
Contributor

The didRender hook is called during both render and re-render after the template has rendered and the DOM updated.

whereas the didInsertElement hook is called only during initial render. I notice in this PR a lot of refactoring from using didInsertElement to using didRender but a lot of the code involves the settings of minimum widths, etc. Do these values need to be recalculated on rerender or should they be left to be set in didInsertElement?

@AdamWard1995
Copy link
Contributor Author

@notmessenger I had originally wrote it as using didInsertElement so that the cells would only be aligned once. As I tried to integrate this in mcp-ui I noticed that as rows are added and removed through filtering for example, the new rows didn't get aligned

@notmessenger
Copy link
Contributor

@AdamWard1995 are all (re)calculations needed or just some of them? If all that's fine, just seems while glancing at it (only) that minimum widths would not need to be, for example.

@AdamWard1995
Copy link
Contributor Author

So in the case that a new row is added, a cell may be wider than the current minimum width in which case the whole column needs to be realigned. I can play for a bit and see if it is possible to only do the alignment when this situation occurs

@@ -84,6 +84,7 @@
}}
{{#each items as |item index|}}
{{frost-table-row
class=(if isSelectable 'selectable' '')
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so it is in frost-table-row, but in this case don't want to set isSelectable to true for middle and right sections otherwise they'll get their own selection cell too. Only want a selection cell in the left section

Copy link
Contributor Author

Choose a reason for hiding this comment

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

....but we want the middle and right section rows to have this class so that the cursor pointer changes

@AdamWard1995
Copy link
Contributor Author

@notmessenger did a best effort to minimize the number of DOM accesses. It should only realign the entire table when the number of rows changes

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling e59d04c on AdamWard1995:flexTable into ** on ciena-frost:master**.

@AdamWard1995 AdamWard1995 merged commit 76cb805 into ciena-frost:master Aug 24, 2017
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.

None yet

5 participants