-
Notifications
You must be signed in to change notification settings - Fork 355
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
Conversation
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.
10c0062
to
961a5d5
Compare
this.set('selection', rows.slice(-5)); | ||
|
||
await table.rows.objectAt(0).checkbox.click(); | ||
assert.ok(true, 'no error'); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
e5bad9e
to
ea8d909
Compare
Modify
CollapseTree
:setupAllRowMeta
that walks all the table's rows andsets 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 haverowMetas. 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.
mapSelectionToMeta
to contain the extra complexity of finding the row metas (and calling ofsetupAllRowMeta
if needed) for a selectionIt's also possible for a
selection
to contain a row without a correspondingrowMeta 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 functionregisterTestWarnHandler
that can be used to capture and assert on runtimeEmber.warn
warnings that happen during a test.