Skip to content

Commit

Permalink
Focus wrapper element once gets closed. (#374)
Browse files Browse the repository at this point in the history
Co-authored-by: José Rio <[email protected]>
  • Loading branch information
gnbm and joselrio authored Dec 16, 2024
1 parent d2e0f5e commit bdbbbca
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist-archive/virtual-select-1.0.46.min.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions dist/virtual-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,6 @@ var VirtualSelect = /*#__PURE__*/function () {
this.$dropboxContainerTop.focus();
} else {
this.closeDropbox();
this.$wrapper.focus();
}
return;
}
Expand All @@ -995,7 +994,6 @@ var VirtualSelect = /*#__PURE__*/function () {
var wrapper = this.showAsPopup ? this.$wrapper : this.$dropboxWrapper;
if ((document.activeElement === wrapper || wrapper.contains(document.activeElement)) && !this.keepAlwaysOpen) {
this.closeDropbox();
this.$wrapper.focus();
return;
}
}
Expand Down Expand Up @@ -2740,6 +2738,7 @@ var VirtualSelect = /*#__PURE__*/function () {
} else {
this.afterHidePopper();
}
this.$wrapper.focus();
}
}, {
key: "afterHidePopper",
Expand Down
2 changes: 1 addition & 1 deletion dist/virtual-select.min.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions docs/assets/virtual-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,6 @@ var VirtualSelect = /*#__PURE__*/function () {
this.$dropboxContainerTop.focus();
} else {
this.closeDropbox();
this.$wrapper.focus();
}
return;
}
Expand All @@ -995,7 +994,6 @@ var VirtualSelect = /*#__PURE__*/function () {
var wrapper = this.showAsPopup ? this.$wrapper : this.$dropboxWrapper;
if ((document.activeElement === wrapper || wrapper.contains(document.activeElement)) && !this.keepAlwaysOpen) {
this.closeDropbox();
this.$wrapper.focus();
return;
}
}
Expand Down Expand Up @@ -2740,6 +2738,7 @@ var VirtualSelect = /*#__PURE__*/function () {
} else {
this.afterHidePopper();
}
this.$wrapper.focus();
}
}, {
key: "afterHidePopper",
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/virtual-select.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/virtual-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,10 @@ export class VirtualSelect {
this.$dropboxContainerTop.focus();
} else {
this.closeDropbox();
this.$wrapper.focus();
}
return;
}

if (document.activeElement === this.$searchInput && key === 9) {
e.preventDefault();
this.focusFirstVisibleOption();
Expand All @@ -542,7 +542,6 @@ export class VirtualSelect {
const wrapper = this.showAsPopup ? this.$wrapper : this.$dropboxWrapper;
if ((document.activeElement === wrapper || wrapper.contains(document.activeElement)) && !this.keepAlwaysOpen) {
this.closeDropbox();
this.$wrapper.focus();
return;
}
}
Expand Down Expand Up @@ -2363,6 +2362,8 @@ export class VirtualSelect {
} else {
this.afterHidePopper();
}

this.$wrapper.focus();
}

afterHidePopper() {
Expand Down

0 comments on commit bdbbbca

Please sign in to comment.