mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-08 08:27:19 +00:00
fix: restore Enter-to-confirm in ConfirmDialog by focusing the Confirm button
This commit is contained in:
parent
810378c0b8
commit
d9f04ab9df
1 changed files with 6 additions and 1 deletions
|
|
@ -36,6 +36,7 @@
|
|||
}
|
||||
|
||||
let modalElement = null;
|
||||
let confirmButtonElement: HTMLButtonElement | null = null;
|
||||
let mounted = false;
|
||||
|
||||
let focusTrap: FocusTrap.FocusTrap | null = null;
|
||||
|
|
@ -81,7 +82,10 @@
|
|||
$: if (mounted) {
|
||||
if (show && modalElement) {
|
||||
document.body.appendChild(modalElement);
|
||||
focusTrap = FocusTrap.createFocusTrap(modalElement);
|
||||
focusTrap = FocusTrap.createFocusTrap(modalElement, {
|
||||
initialFocus: () =>
|
||||
modalElement.querySelector('input, textarea, select') ?? confirmButtonElement ?? undefined
|
||||
});
|
||||
focusTrap.activate();
|
||||
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
|
|
@ -195,6 +199,7 @@
|
|||
{cancelLabel}
|
||||
</button>
|
||||
<button
|
||||
bind:this={confirmButtonElement}
|
||||
class="text-sm bg-gray-900 hover:bg-gray-900/90 text-gray-100 dark:bg-gray-100 dark:hover:bg-gray-100/90 dark:text-gray-800 font-normal w-full py-1.5 rounded-full transition"
|
||||
on:click={() => {
|
||||
confirmHandler();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue