Skip to content

Commit

Permalink
Fixed #5106 - Change visual focus behavior for UI/UX enhancement on s…
Browse files Browse the repository at this point in the history
…ome components
  • Loading branch information
mertsincan committed Jan 18, 2024
1 parent 55c68a0 commit bed58e4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions components/lib/cascadeselect/CascadeSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ export default {
isOptionGroup(option, level) {
return Object.prototype.hasOwnProperty.call(option, this.optionGroupChildren[level]);
},
getProccessedOptionLabel(processedOption) {
getProccessedOptionLabel(processedOption = {}) {
const grouped = this.isProccessedOptionGroup(processedOption);
return grouped ? this.getOptionGroupLabel(processedOption.option, processedOption.level) : this.getOptionLabel(processedOption.option);
},
isProccessedOptionGroup(processedOption) {
return ObjectUtils.isNotEmpty(processedOption.children);
return ObjectUtils.isNotEmpty(processedOption?.children);
},
show(isFocus) {
this.$emit('before-show');
Expand Down Expand Up @@ -285,14 +285,14 @@ export default {
activeOptionPath.push(processedOption);
this.focusedOptionInfo = { index, level, parentKey };
this.focusedOptionInfo = originalEvent?.type === 'click' ? { index: -1, level, parentKey } : { index, level, parentKey };
this.activeOptionPath = activeOptionPath;
grouped ? this.onOptionGroupSelect(originalEvent, processedOption) : this.onOptionSelect(originalEvent, processedOption, isHide);
isFocus && DomHandler.focus(this.$refs.focusInput);
},
onOptionSelect(event, processedOption, isHide = true) {
const value = this.getOptionValue(processedOption.option);
const value = this.getOptionValue(processedOption?.option);
this.activeOptionPath.forEach((p) => (p.selected = true));
this.updateModel(event, value);
Expand Down Expand Up @@ -361,9 +361,9 @@ export default {
onArrowLeftKey(event) {
if (this.overlayVisible) {
const processedOption = this.visibleOptions[this.focusedOptionInfo.index];
const parentOption = this.activeOptionPath.find((p) => p.key === processedOption.parentKey);
const parentOption = this.activeOptionPath.find((p) => p.key === processedOption?.parentKey);
const matched = this.focusedOptionInfo.parentKey === '' || (parentOption && parentOption.key === this.focusedOptionInfo.parentKey);
const root = ObjectUtils.isEmpty(processedOption.parent);
const root = ObjectUtils.isEmpty(processedOption?.parent);
if (matched) {
this.activeOptionPath = this.activeOptionPath.filter((p) => p.parentKey !== this.focusedOptionInfo.parentKey);
Expand All @@ -384,10 +384,10 @@ export default {
const grouped = this.isProccessedOptionGroup(processedOption);
if (grouped) {
const matched = this.activeOptionPath.some((p) => processedOption.key === p.key);
const matched = this.activeOptionPath.some((p) => processedOption?.key === p.key);
if (matched) {
this.focusedOptionInfo = { index: -1, parentKey: processedOption.key };
this.focusedOptionInfo = { index: -1, parentKey: processedOption?.key };
this.searchValue = '';
this.onArrowDownKey(event);
} else {
Expand Down
2 changes: 1 addition & 1 deletion components/lib/listbox/Listbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export default {
this.multiple ? this.onOptionSelectMultiple(event, option) : this.onOptionSelectSingle(event, option);
this.optionTouched = false;
index !== -1 && (this.focusedOptionIndex = index);
index !== -1 && (this.focusedOptionIndex = event?.type === 'click' ? -1 : index);
},
onOptionMouseDown(event, index) {
this.changeFocusedOptionIndex(event, index);
Expand Down
2 changes: 1 addition & 1 deletion components/lib/multiselect/MultiSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ export default {
else value = [...(this.modelValue || []), this.getOptionValue(option)];
this.updateModel(event, value);
index !== -1 && (this.focusedOptionIndex = index);
index !== -1 && (this.focusedOptionIndex = event?.type === 'click' ? -1 : index);
isFocus && DomHandler.focus(this.$refs.focusInput);
},
onOptionMouseMove(event, index) {
Expand Down
2 changes: 1 addition & 1 deletion components/lib/orderlist/OrderList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ export default {
const selectedId = DomHandler.find(this.list, '[data-pc-section="item"]')[index].getAttribute('id');
this.focusedOptionIndex = selectedId;
this.focusedOptionIndex = event?.type === 'click' ? -1 : selectedId;
if (metaSelection) {
const metaKey = event.metaKey || event.ctrlKey;
Expand Down
2 changes: 1 addition & 1 deletion components/lib/picklist/PickList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ export default {
const metaSelection = this.itemTouched ? false : this.metaKeySelection;
const selectedId = DomHandler.find(this.$refs[listType].$el, '[data-pc-section="item"]')[index].getAttribute('id');
this.focusedOptionIndex = selectedId;
this.focusedOptionIndex = event?.type === 'click' ? -1 : selectedId;
let _selection;
if (metaSelection) {
Expand Down

0 comments on commit bed58e4

Please sign in to comment.