-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
[Feature] Add option to select one row at a time in data tables #2973
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #2973 +/- ##
==========================================
+ Coverage 83.66% 84.58% +0.92%
==========================================
Files 145 143 -2
Lines 3348 3348
Branches 1057 1028 -29
==========================================
+ Hits 2801 2832 +31
+ Misses 398 374 -24
+ Partials 149 142 -7
Continue to review full report at Codecov.
|
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.
Thank you for your contribution. Personally I like the functionality, what about @vuetifyjs/collaborators ? I'm not sure about the name though. Radio implies that it will be using a radio button. Perhaps single-select
? Or do we have an existing name for this in another component?
Also, please add one or more tests.
src/mixins/data-iterable.js
Outdated
@@ -275,7 +276,7 @@ export default { | |||
) | |||
|
|||
return this.hideActions && | |||
!this.hasPagination | |||
!this.hasPagination |
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.
revert this
src/mixins/data-iterable.js
Outdated
else selected = selected.filter(i => i[keyProp] !== itemKey) | ||
if (value) { | ||
if (this.radioSelect) { | ||
selected.length = 0 |
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.
can be simplified to selected = [item]
Faced this issue recently. Got around it by having |
@nekosaur I'm working on some tests at the moment; trying to decide whether to run them against the |
@nekosaur I'm not sure this can be tested properly using the current version of There's an open issue here discussing the problem: vuejs/vue-test-utils#156 |
We're using avoriaz now, not vue-test-utils (althouh there are plans to switch to it), and we're testing scoped slots, for example: https://github.com/vuetifyjs/vuetify/blob/dev/src/components/VDataTable/VDataTable.spec.js#L97 |
Closing due to inactivity. |
Description
Option to select one row at a time in a data table, radio-button style. Selecting a new row will clear the previous selection.
Adds
radioSelect
boolean prop tov-data-table
, plus code to clear previous selection if the prop is true.Motivation and Context
Allows the user to provide extra functionality in custom components based on a guaranteed single-row selection in the data table; a preview pane, for example.
Resolves #2960
How Has This Been Tested?
Jest.
No new test, as modified code on
data-iterable
isn't currently subject to unit testingMarkup:
Types of changes
Checklist:
master
for bug fixes,dev
for new features and breaking changes).