disclosure dropdown can steal focus when closing
From gitlab!134114 (comment 1681306973)
We click an item in disclosure dropdown, a component is mounted that wants an input to be autofocused, then disclosure dropdown closes and autofocus goes back to the dropdown trigger.
Maybe checking that focus is still inside the dropdown (this probably misses a buinch of cases I have not thought of...)
diff --git a/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.vue b/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.vue
index 118f573b5..f549993d2 100644
--- a/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.vue
+++ b/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.vue
@@ -340,7 +340,8 @@ export default {
if (
this.autoClose &&
e.target.closest(ITEM_SELECTOR) &&
- e.target.closest(DROPDOWN_SELECTOR) === this.$refs.baseDropdown.$el
+ e.target.closest(DROPDOWN_SELECTOR) === this.$refs.baseDropdown.$el &&
+ document.activeElement.closest(DROPDOWN_SELECTOR) === this.$refs.baseDropdown.$el
) {
this.closeAndFocus();
}