dropdown and input fixes

This commit is contained in:
konnorrogers
2024-06-18 15:12:40 -04:00
parent 8c6f86abe0
commit f1627630ad
2 changed files with 13 additions and 7 deletions

View File

@@ -295,9 +295,9 @@ export default class WaDropdown extends WebAwesomeElement {
// Either the tag hasn't registered, or it hasn't rendered.
// So, wait for the tag to register, and then try again.
if (target === undefined) {
if (target === undefined || target === null) {
customElements.whenDefined(tagName).then(async () => {
await (target as WaButton | WaIconButton).updateComplete;
await (accessibleTrigger as WaButton | WaIconButton).updateComplete;
this.updateAccessibleTrigger();
});

View File

@@ -260,15 +260,21 @@ export default class WaInput extends WebAwesomeFormAssociatedElement {
return;
}
const button = [...form.elements].find((el: HTMLButtonElement) => el.type === 'submit' && !el.disabled) as
const formElements = [...form.elements]
// If we're the only formElement, we submit like a native input.
if (formElements.length === 1) {
form.requestSubmit(null);
return;
}
const button = formElements.find((el: HTMLButtonElement) => el.type === 'submit' && !el.matches(":disabled")) as
| undefined
| HTMLButtonElement
| WaButton;
if (!button) {
form.requestSubmit(null);
return;
}
// No button found, don't submit.
if (!button) { return }
if (button.tagName.toLowerCase() === 'button') {
form.requestSubmit(button);