From cb6ee137f2fe9bfb0175a41d29606de637365087 Mon Sep 17 00:00:00 2001 From: Daniel Michel <65034538+daniel-michel@users.noreply.github.com> Date: Sat, 20 Apr 2024 16:22:02 +0200 Subject: [PATCH] Improve modals (#840) * Adjust picker input to take up all remaining space * Improve modals and buttons * Remove confusing focus of scrollable result list in Firefox * Adjust css for dark themes, add background for text field in prompt Seperate accent color for text to increase contrast in dark theme Set css color-scheme to dark for dark theme * Fix buggy when entering very long text in picker * Prevent key events from propagating outside of modals * Always show focus on button * Add the keydown event listener directly to the mini editor * Do not refocus the mini editor when it loses focus and refactoring of the AlwaysShownModal. * Fix reference to button and mini editor focus in chrome * Fix selected option index capping in filter when using page down --- web/components/basic_modals.tsx | 171 +++++++++++++++++++++----------- web/components/filter.tsx | 15 ++- web/components/mini_editor.tsx | 63 +++++------- web/styles/colors.scss | 33 ++++++ web/styles/modals.scss | 27 +++-- web/styles/theme.scss | 34 ++++++- 6 files changed, 233 insertions(+), 110 deletions(-) diff --git a/web/components/basic_modals.tsx b/web/components/basic_modals.tsx index 150b1ce8..79db6ca2 100644 --- a/web/components/basic_modals.tsx +++ b/web/components/basic_modals.tsx @@ -1,6 +1,7 @@ import { CompletionContext, CompletionResult } from "@codemirror/autocomplete"; -import { useRef, useState } from "preact/hooks"; +import { useEffect, useRef, useState } from "preact/hooks"; import { MiniEditor } from "./mini_editor.tsx"; +import { ComponentChildren, Ref } from "preact"; export function Prompt({ message, @@ -19,7 +20,11 @@ export function Prompt({ }) { const [text, setText] = useState(defaultValue || ""); const returnEl = ( -