bluzky/nice-select2

Hitting "return/enter" key submits the form instead of selecting an option in search.

mattneal-stafflink opened this issue · 0 comments

As above. In other single/multi select fields, hitting enter selects the option. In Nice-Select2, it submits the form. There should be a way to prevent this from happening. For the moment I'm just using my own solution:

	NiceSelect.bind(
		document.getElementById('property_location'),
		{searchable: true, placeholder: 'Search'}
	);

	const searchForm = document.getElementById('property-search-form');
	
	searchForm.addEventListener('submit', function(e) {
		if ( searchForm.querySelector('.nice-select-search:focus') ) {
			e.preventDefault();
			document.getElementById("PrimarySubmit").focus();
		}
	});

Which works fine, but I feel like this should be the default...