Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions BrickSelect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ const BrickSelect = {

this._processOptions();
this._nativeSelect.required = this.hasAttribute('required');

if (!!this.getAttribute('form')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use hasAttribute here

this._nativeSelect.setAttribute("form",this.getAttribute('form'));
}

this.addEventListener('click', this._onSelectOpened.bind(this));
this.addEventListener('change', this._onSelectionChanged.bind(this));
Expand Down Expand Up @@ -225,9 +229,12 @@ const BrickSelect = {

event.preventDefault();

if (event.target.form.querySelector(':invalid') !== event.target) {
const firstInvalidInput = Array.from(event.target.form.elements)
.find(element => element.matches(':invalid'));

if (firstInvalidInput !== event.target) {
return;
}
}

event.target.parentElement.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'smooth' });
},
Expand Down