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

feat(VListItem): add selectable prop #8622

Merged
merged 3 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/docs/src/lang/en/components/Lists.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"color": "Applies specified color to the control when in an **active** state or **input-value** is **true** - it can be the name of material color (for example `success` or `purple`) or css color (`#033` or `rgba(255, 0, 0, 0.5)`)",
"disabled": "Disables the component",
"inputValue": "Controls the **active** state of the item. This is typically used to highlight the component",
"selectable": "Allow text selection inside `v-list-item`. This prop uses [user-select](https://developer.mozilla.org/en-US/docs/Web/CSS/user-select)",
"value": "The value used when a child of a [v-list-item-group](/components/list-item-groups)."
},
"v-list-item-avatar": {
Expand Down
3 changes: 3 additions & 0 deletions packages/vuetify/src/components/VList/VListItem.sass
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
&--disabled
pointer-events: none

&--selectable
user-select: auto

// Element
.v-list-item__action
align-self: center
Expand Down
4 changes: 4 additions & 0 deletions packages/vuetify/src/components/VList/VListItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export default baseMixins.extend<options>().extend({
dense: Boolean,
inactive: Boolean,
link: Boolean,
selectable: {
type: Boolean,
},
tag: {
type: String,
default: 'div',
Expand All @@ -95,6 +98,7 @@ export default baseMixins.extend<options>().extend({
'v-list-item--dense': this.dense,
'v-list-item--disabled': this.disabled,
'v-list-item--link': this.isClickable && !this.inactive,
'v-list-item--selectable': this.selectable,
'v-list-item--three-line': this.threeLine,
'v-list-item--two-line': this.twoLine,
...this.themeClasses,
Expand Down
10 changes: 10 additions & 0 deletions packages/vuetify/src/components/VList/__tests__/VListItem.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ describe('VListItem.ts', () => {
expect(wrapper.classes('v-list-item--link')).toBe(true)
})

it('should have --selectable class if the selectable property is true', () => {
const wrapper = mountFunction({
propsData: {
selectable: true,
},
})

expect(wrapper.classes('v-list-item--selectable')).toBe(true)
})

it('should react to keydown.enter', () => {
const click = jest.fn()
const wrapper = mountFunction({
Expand Down