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

[BUG] Fix cases where manual selection includes unrendered or nonexistent rows #748

Merged
merged 6 commits into from
Jul 31, 2019

Conversation

bantic
Copy link
Member

@bantic bantic commented Jul 29, 2019

Modify CollapseTree:

  • Add a function setupAllRowMeta that walks all the table's rows and
    sets up a row meta for each one. This is called lazily in the case where
    the table has a selection that includes some rows that don't yet have
    rowMetas. This can happen if the selection includes rows that haven't yet
    rendered. The rowMeta for a row is lazily created when it is rendered,
    so rows that haven't yet rendered won't have a row meta. This usually is
    not a problem because in normal user interaction with a table, the user will
    only interact with rows that are rendered. However, it's possible to
    programmatically set a selection, and in this case a row in the selection
    may not yet have been rendered.
  • Add mapSelectionToMeta to contain the extra complexity of finding the row metas (and calling of setupAllRowMeta if needed) for a selection

It's also possible for a selection to contain a row without a corresponding
rowMeta if that row is not part of the table's rows. This is an invalid selection,
and this commit adds an Ember.warning for times when we detect such a case.

Fixes #747

Modifies one of the 747 test cases to assert that the warning is triggered
when ET encounters a selection with a row that is not part of the table. The added warning has the id ember-table.selection-invalid.

Adds a warn-handlers test helper file that provides a function registerTestWarnHandler that can be used to capture and assert on runtime Ember.warn warnings that happen during a test.

Adds several failing tests for #747.
Add a function `setupAllRowMeta` that walks all the table's rows and
sets up a row meta for each one. This is called lazily in the case where
the table has a `selection` that includes some rows that don't yet have
rowMetas. This can happen if the selection includes rows that haven't yet
rendered. The rowMeta for a row is lazily created when it is rendered,
so rows that haven't yet rendered won't have a row meta. This usually is
not a problem because in normal user interaction with a table, the user will
only interact with rows that are rendered. However, it's possible to
programmatically set a selection, and in this case a row in the selection
may not yet have been rendered.

It's also possible for a `selection` to contain a row without a corresponding
rowMeta if that row is not part of the table's rows. This is an invalid selection,
and this commit adds an Ember.warning for times when we detect such a case.

Fixes #747

Modifies one of the 747 test cases to assert that the warning is triggered
when ET encounters a selection with a row that is not part of the table.
@bantic bantic force-pushed the bantic/bug/manual-selection branch from 10c0062 to 961a5d5 Compare July 30, 2019 18:09
@bantic bantic changed the title Failing test for #747 [BUG] Fix cases where manual selection includes unrendered or nonexistent rows Jul 30, 2019
@bantic bantic requested review from cyril-sf and mixonic July 30, 2019 18:14
this.set('selection', rows.slice(-5));

await table.rows.objectAt(0).checkbox.click();
assert.ok(true, 'no error');
Copy link
Member

Choose a reason for hiding this comment

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

Should this also assert that the row is selected when you scroll to it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add an assertion that it is selected, but this row is at the top of the table so will already be in view.

Add `test` condition to warn call in collapse-tree
@bantic bantic force-pushed the bantic/bug/manual-selection branch from e5bad9e to ea8d909 Compare July 30, 2019 19:54
@bantic bantic merged commit 4604929 into master Jul 31, 2019
@bantic bantic deleted the bantic/bug/manual-selection branch July 31, 2019 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

bug after manually setting selection to include un-rendered rows
2 participants