minor dropdown improvements

This commit is contained in:
Aran-Fey
2024-06-23 01:54:05 +02:00
parent c3c8891a83
commit 6e85ca4002
4 changed files with 73 additions and 59 deletions

View File

@@ -159,7 +159,7 @@ export abstract class ComponentBase {
this.innerAlignElement!.classList.add('stretch-child-x');
} else {
this.innerAlignElement!.style.left = `${align[0] * 100}%`;
this.innerAlignElement!.style.width = 'min-content';
this.innerAlignElement!.style.width = 'max-content';
this.innerAlignElement!.classList.remove('stretch-child-x');
transform += `translateX(-${align[0] * 100}%) `;
}
@@ -170,7 +170,7 @@ export abstract class ComponentBase {
this.innerAlignElement!.classList.add('stretch-child-y');
} else {
this.innerAlignElement!.style.top = `${align[1] * 100}%`;
this.innerAlignElement!.style.height = 'min-content';
this.innerAlignElement!.style.height = 'max-content';
this.innerAlignElement!.classList.remove('stretch-child-y');
transform += `translateY(-${align[1] * 100}%) `;
}

View File

@@ -389,7 +389,11 @@ export class DropdownComponent extends ComponentBase {
this._highlightOption(match);
});
match.addEventListener('click', (event) => {
// With a `click` handler, the <input> element loses focus for a
// little while, which is noticeable because the floating label will
// quickly move down and then back up. To avoid this, we use
// `mousedown` instead.
match.addEventListener('mousedown', (event) => {
this.submitInput(optionName);
markEventAsHandled(event);
});