From 2ec2a50f4849f12aa6db73a96acd57ce74c2a85f Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Sat, 15 Dec 2018 16:48:00 +0300 Subject: [PATCH] Use p-focus class for consistency --- src/components/selectbutton/SelectButton.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/selectbutton/SelectButton.vue b/src/components/selectbutton/SelectButton.vue index 1a7c1735d..91514f2d1 100644 --- a/src/components/selectbutton/SelectButton.vue +++ b/src/components/selectbutton/SelectButton.vue @@ -2,8 +2,8 @@
+ :tabindex="isOptionDisabled(option) ? null : '0'" @focus="onFocus($event, i)" @blur="onBlur($event)" + :class="['p-button p-component p-button-text-only', {'p-highlight': isSelected(option), 'p-disabled': isOptionDisabled(option), 'p-focus': (i === focusedIndex)}]"> {{getOptionLabel(option)}} @@ -26,6 +26,11 @@ export default { optionValue: null, optionDisabled: null }, + data() { + return { + focusedIndex: null + }; + }, methods: { getOptionLabel(option) { return ObjectUtils.resolveFieldData(option, this.optionLabel); @@ -76,6 +81,14 @@ export default { } return selected; + }, + onFocus(event, index) { + this.focusedIndex = index; + this.$emit('focus', event); + }, + onBlur() { + this.focusedIndex = null + this.$emit('blur', event); } } }