Skip to content

Commit

Permalink
fix: popover closing when renaming file (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara authored Mar 24, 2022
1 parent 67e0bf0 commit 1bdda36
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { FOCUSABLE_BUT_NOT_TABBABLE } from '@/constants';
import { KeyboardKey } from '@/services/ioService';
import { formatSizeToReadableString } from '@standardnotes/filepicker';
import { IconType, SNFile } from '@standardnotes/snjs';
Expand Down Expand Up @@ -33,6 +34,7 @@ export const PopoverFileItem: FunctionComponent<PopoverFileItemProps> = ({
}) => {
const [fileName, setFileName] = useState(file.name);
const [isRenamingFile, setIsRenamingFile] = useState(false);
const itemRef = useRef<HTMLDivElement>(null);
const fileNameInputRef = useRef<HTMLInputElement>(null);

useEffect(() => {
Expand All @@ -58,7 +60,7 @@ export const PopoverFileItem: FunctionComponent<PopoverFileItemProps> = ({

const handleFileNameInputKeyDown = (event: KeyboardEvent) => {
if (event.key === KeyboardKey.Enter) {
fileNameInputRef.current?.blur();
itemRef.current?.focus();
}
};

Expand All @@ -67,7 +69,11 @@ export const PopoverFileItem: FunctionComponent<PopoverFileItemProps> = ({
};

return (
<div className="flex items-center justify-between p-3">
<div
ref={itemRef}
className="flex items-center justify-between p-3 focus:shadow-none"
tabIndex={FOCUSABLE_BUT_NOT_TABBABLE}
>
<div className="flex items-center">
{getFileIconComponent(
getIconType(file.mimeType),
Expand Down

0 comments on commit 1bdda36

Please sign in to comment.