Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix: keep folder rename textarea focused after choosing Rename
Richie McIlroy8dcf64ffdcc6
diff --git a/apps/web/app/(org)/dashboard/caps/components/FoldersDropdown.tsx b/apps/web/app/(org)/dashboard/caps/components/FoldersDropdown.tsxindex 52b0fe7b8..a6d3dce0e 100644--- a/apps/web/app/(org)/dashboard/caps/components/FoldersDropdown.tsx+++ b/apps/web/app/(org)/dashboard/caps/components/FoldersDropdown.tsx@@ -13,7 +13,7 @@ import {faTrash,} from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import type { RefObject } from "react";+import { type RefObject, useRef } from "react";interface FoldersDropdownProps {id: string;@@ -38,6 +38,8 @@ export const FoldersDropdown = ({canMove,onMove,}: FoldersDropdownProps) => {+ const renameRequestedRef = useRef(false);+return (<DropdownMenu><DropdownMenuTrigger asChild>@@ -55,7 +57,25 @@ export const FoldersDropdown = ({<FontAwesomeIcon className="text-gray-12 size-4" icon={faEllipsis} /></button></DropdownMenuTrigger>- <DropdownMenuContent>+ <DropdownMenuContent+ onCloseAutoFocus={(event) => {+ // Radix restores focus to the trigger on close from a setTimeout(0)+ // scheduled when the menu unmounts, so it always lands after the+ // rename focus calls below. That blur makes the textarea's onBlur+ // exit rename mode instantly (reported as "flashes then can't+ // type"). Opt out for rename only; other items still restore focus+ // to the trigger.+ if (!renameRequestedRef.current) return;+ renameRequestedRef.current = false;+ event.preventDefault();+ // Fallback only: never take focus back off wherever the user has+ // since clicked.+ if (document.activeElement === document.body) {+ nameRef.current?.focus();+ nameRef.current?.select();+ }+ }}+ >{(() => {type FolderDropdownItem = {label: string;@@ -67,6 +87,7 @@ export const FoldersDropdown = ({label: "Rename",icon: faPencil,onClick: () => {+ renameRequestedRef.current = true;setIsRenaming(true);setTimeout(() => {nameRef.current?.focus();