diff --git a/docs/src/examples/KeyGroupNavigation/FormControls.vue b/docs/src/examples/KeyGroupNavigation/FormControls.vue
index 4d46ba0f6659..25f8d4c1dc12 100644
--- a/docs/src/examples/KeyGroupNavigation/FormControls.vue
+++ b/docs/src/examples/KeyGroupNavigation/FormControls.vue
@@ -8,6 +8,9 @@
+
+
+
@@ -17,7 +20,8 @@ export default {
data () {
return {
editor: 'What you see is what you get.',
- date: '2019/02/01'
+ date: '2019/02/01',
+ rating: 3
}
}
}
diff --git a/docs/src/examples/QRating/Basic.vue b/docs/src/examples/QRating/Basic.vue
index ad8ef09f7409..bd7268961287 100644
--- a/docs/src/examples/QRating/Basic.vue
+++ b/docs/src/examples/QRating/Basic.vue
@@ -1,6 +1,6 @@
-
+
+
+
+
+
diff --git a/docs/src/pages/vue-components/rating.md b/docs/src/pages/vue-components/rating.md
index f0b2503ff433..40b49a69a8c7 100644
--- a/docs/src/pages/vue-components/rating.md
+++ b/docs/src/pages/vue-components/rating.md
@@ -17,6 +17,10 @@ Quasar Rating is a Component which allows users to rate items, usually known as
+### Vertical
+
+
+
### Icons
diff --git a/ui/dev/src/pages/form/rating.vue b/ui/dev/src/pages/form/rating.vue
index 05eefd4fb371..2880be6dc1ff 100644
--- a/ui/dev/src/pages/form/rating.vue
+++ b/ui/dev/src/pages/form/rating.vue
@@ -5,15 +5,20 @@
Model {{ ratingModel }}
-
-
-
+
+
+
+
+
+
-
-
+
+
+
+
= i) || (this.mouseModel > 0 && this.mouseModel >= i),
+ active = this.mouseModel >= i || (this.mouseModel === 0 && this.value >= i),
half = halfIndex === i && this.mouseModel < i,
exSelected = this.mouseModel > 0 && (half === true ? ceil : this.value) >= i && this.mouseModel < i,
color = half === true
@@ -123,6 +132,7 @@ export default Vue.extend({
(active === true || half === true ? ' q-rating__icon--active' : '') +
(exSelected === true ? ' q-rating__icon--exselected' : '') +
(this.mouseModel === i ? ' q-rating__icon--hovered' : '') +
+ (ceil === i ? ' q-key-group-navigation__refocus' : '') +
(color !== void 0 ? ` text-${color}` : '')
})
}
@@ -137,6 +147,15 @@ export default Vue.extend({
if (this.readonly === true) {
return { 'aria-readonly': 'true' }
}
+ },
+
+ directives () {
+ return [{
+ name: 'key-group-navigation',
+ modifiers: {
+ [this.vertical === true ? 'vertical' : 'horizontal']: true
+ }
+ }]
}
},
@@ -159,23 +178,9 @@ export default Vue.extend({
},
__keyup (e, i) {
- switch (e.keyCode) {
- case 13:
- case 32:
- this.__set(i)
- return stopAndPrevent(e)
- case 37: // LEFT ARROW
- case 40: // DOWN ARROW
- if (this.$refs[`rt${i - 1}`]) {
- this.$refs[`rt${i - 1}`].focus()
- }
- return stopAndPrevent(e)
- case 39: // RIGHT ARROW
- case 38: // UP ARROW
- if (this.$refs[`rt${i + 1}`]) {
- this.$refs[`rt${i + 1}`].focus()
- }
- return stopAndPrevent(e)
+ if ([13, 32].indexOf(e.keyCode) > -1) {
+ this.__set(i)
+ stopAndPrevent(e)
}
}
},
@@ -185,14 +190,14 @@ export default Vue.extend({
child = [],
tabindex = this.editable === true ? 0 : null
- this.stars.forEach(({ classes, name }, index) => {
+ this.stars.forEach(({ classes, name, active }, index) => {
const i = index + 1
child.push(
h('div', {
key: i,
ref: `rt${i}`,
- class: 'q-rating__icon-container flex flex-center',
+ staticClass: 'q-rating__icon-container flex flex-center',
attrs: { tabindex },
on: cache(this, 'i#' + i, {
click: () => { this.__set(i) },
@@ -214,10 +219,11 @@ export default Vue.extend({
}
return h('div', {
- staticClass: 'q-rating row inline items-center q-key-group-navigation--ignore-key',
+ staticClass: 'q-rating inline',
class: this.classes,
style: this.sizeStyle,
attrs: this.attrs,
+ directives: this.directives,
on: { ...this.qListeners }
}, child)
}
diff --git a/ui/src/components/rating/QRating.json b/ui/src/components/rating/QRating.json
index 8f730c70cb7b..9256b256a170 100644
--- a/ui/src/components/rating/QRating.json
+++ b/ui/src/components/rating/QRating.json
@@ -96,6 +96,13 @@
"category": "model"
},
+ "vertical": {
+ "type": "Boolean",
+ "desc": "Vertical display",
+ "category": "style",
+ "addedIn": "v1.16.0"
+ },
+
"readonly": {
"extends": "readonly"
},