Skip to content

Commit

Permalink
feat: added handler for a file selection abort of the image input
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillSerg committed Jun 23, 2024
1 parent 2486ef0 commit a264c86
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/ImageIconBtn.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRef } from 'react';
import { useEffect, useRef } from 'react';
import { useAtom } from 'jotai';
import { ElementProps } from '../types/CommonTypes';
import { creationInitialElementAtom } from '../store/store';
Expand Down Expand Up @@ -30,6 +30,15 @@ const ImageIconBtn = ({ className, handlerClick }: Props) => {
}
};

// to handle a file selection abort
useEffect(() => {
if (fileInputRef.current) {
fileInputRef.current.addEventListener('cancel', () => {
handlerClick({ type_name: 'free', width: 1, height: 1 });
});
}
}, [handlerClick]);

return (
<button
className={className}
Expand Down

0 comments on commit a264c86

Please sign in to comment.