mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-12-23 22:58:17 -05:00
Address code review: improve type safety and accessibility
Co-authored-by: seanmorley15 <98704938+seanmorley15@users.noreply.github.com>
This commit is contained in:
@@ -23,12 +23,12 @@
|
|||||||
let isOpen: boolean = false;
|
let isOpen: boolean = false;
|
||||||
let isEmojiPickerVisible: boolean = false;
|
let isEmojiPickerVisible: boolean = false;
|
||||||
|
|
||||||
function toggleEmojiPicker(event: Event) {
|
function toggleEmojiPicker(event: MouseEvent) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
isEmojiPickerVisible = !isEmojiPickerVisible;
|
isEmojiPickerVisible = !isEmojiPickerVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleDropdown(event: Event) {
|
function toggleDropdown(event: MouseEvent) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
isOpen = !isOpen;
|
isOpen = !isOpen;
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
isEmojiPickerVisible = false;
|
isEmojiPickerVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function custom_category(event: Event) {
|
function custom_category(event: MouseEvent) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
new_category.name = new_category.display_name.toLowerCase().replace(/ /g, '_');
|
new_category.name = new_category.display_name.toLowerCase().replace(/ /g, '_');
|
||||||
@@ -56,6 +56,8 @@
|
|||||||
isEmojiPickerVisible = false;
|
isEmojiPickerVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prevent Enter key from closing dropdown or submitting parent forms
|
||||||
|
// This is especially important in Safari where Enter can trigger unexpected behaviors
|
||||||
function handleInputKeydown(event: KeyboardEvent) {
|
function handleInputKeydown(event: KeyboardEvent) {
|
||||||
if (event.key === 'Enter') {
|
if (event.key === 'Enter') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -94,6 +96,8 @@
|
|||||||
type="button"
|
type="button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
class="btn btn-outline w-full justify-between sm:h-auto h-12"
|
class="btn btn-outline w-full justify-between sm:h-auto h-12"
|
||||||
|
aria-expanded={isOpen}
|
||||||
|
aria-haspopup="true"
|
||||||
on:click={toggleDropdown}
|
on:click={toggleDropdown}
|
||||||
>
|
>
|
||||||
<span class="flex items-center gap-2">
|
<span class="flex items-center gap-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user