Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mattneal-stafflink opened this issue Mar 17, 2023 · 0 comments

Comments

@mattneal-stafflink
Copy link

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant