mirror of
https://github.com/tenrok/vue-select.git
synced 2026-05-17 02:29:37 +03:00
fix: allow mouse events in the search input (#1092)
Co-authored-by: Doug Kurucz <doug.kurucz@twosixlabs.com> Co-authored-by: Jeff <sagalbot@gmail.com>
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
import { selectWithProps } from "../helpers";
|
||||
import OpenIndicator from "../../src/components/OpenIndicator";
|
||||
|
||||
const preventDefault = jest.fn()
|
||||
|
||||
function clickEvent (currentTarget) {
|
||||
return { currentTarget, preventDefault }
|
||||
}
|
||||
|
||||
describe("Toggling Dropdown", () => {
|
||||
it("should not open the dropdown when the el is clicked but the component is disabled", () => {
|
||||
const Select = selectWithProps({ disabled: true });
|
||||
Select.vm.toggleDropdown({ target: Select.vm.$refs.search });
|
||||
Select.vm.toggleDropdown(clickEvent(Select.vm.$refs.search));
|
||||
expect(Select.vm.open).toEqual(false);
|
||||
});
|
||||
|
||||
@@ -14,10 +20,23 @@ describe("Toggling Dropdown", () => {
|
||||
options: [{ label: "one" }]
|
||||
});
|
||||
|
||||
Select.vm.toggleDropdown({ target: Select.vm.$refs.search });
|
||||
Select.vm.toggleDropdown(clickEvent(Select.vm.$refs.search));
|
||||
expect(Select.vm.open).toEqual(true);
|
||||
});
|
||||
|
||||
it("should not close the dropdown when the el is clicked and enableMouseInputSearch is set to true", () => {
|
||||
const Select = selectWithProps({
|
||||
value: [{ label: "one" }],
|
||||
options: [{ label: "one" }],
|
||||
enableMouseSearchInput: true
|
||||
});
|
||||
|
||||
Select.vm.toggleDropdown(clickEvent(Select.vm.$refs.search));
|
||||
expect(Select.vm.open).toEqual(true);
|
||||
Select.vm.toggleDropdown(clickEvent(Select.vm.$el));
|
||||
expect(Select.vm.open).toEqual(false)
|
||||
});
|
||||
|
||||
it("should open the dropdown when the selected tag is clicked", () => {
|
||||
const Select = selectWithProps({
|
||||
value: [{ label: "one" }],
|
||||
@@ -26,7 +45,7 @@ describe("Toggling Dropdown", () => {
|
||||
|
||||
const selectedTag = Select.find(".vs__selected").element;
|
||||
|
||||
Select.vm.toggleDropdown({ target: selectedTag });
|
||||
Select.vm.toggleDropdown(clickEvent(selectedTag));
|
||||
expect(Select.vm.open).toEqual(true);
|
||||
});
|
||||
|
||||
@@ -35,7 +54,7 @@ describe("Toggling Dropdown", () => {
|
||||
const spy = jest.spyOn(Select.vm.$refs.search, "blur");
|
||||
|
||||
Select.vm.open = true;
|
||||
Select.vm.toggleDropdown({ target: Select.vm.$el });
|
||||
Select.vm.toggleDropdown(clickEvent(Select.vm.$el));
|
||||
|
||||
expect(spy).toHaveBeenCalled();
|
||||
});
|
||||
@@ -133,7 +152,9 @@ describe("Toggling Dropdown", () => {
|
||||
const Select = selectWithProps({
|
||||
noDrop: true,
|
||||
});
|
||||
Select.vm.toggleDropdown({ target: Select.vm.$refs.search });
|
||||
|
||||
Select.vm.toggleDropdown(clickEvent(Select.vm.$refs.search));
|
||||
|
||||
expect(Select.vm.open).toEqual(true);
|
||||
await Select.vm.$nextTick();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user