mirror of
				https://github.com/immich-app/immich.git
				synced 2025-10-31 10:37:11 -04:00 
			
		
		
		
	fix(web): paste event in input fields (#12297)
This commit is contained in:
		
							parent
							
								
									c3a8ddaaf2
								
							
						
					
					
						commit
						c7ddd0b44a
					
				| @ -15,7 +15,7 @@ export type ShortcutOptions<T = HTMLElement> = { | |||||||
|   preventDefault?: boolean; |   preventDefault?: boolean; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const shouldIgnoreShortcut = (event: KeyboardEvent): boolean => { | export const shouldIgnoreEvent = (event: KeyboardEvent | ClipboardEvent): boolean => { | ||||||
|   if (event.target === event.currentTarget) { |   if (event.target === event.currentTarget) { | ||||||
|     return false; |     return false; | ||||||
|   } |   } | ||||||
| @ -52,7 +52,7 @@ export const shortcuts = <T extends HTMLElement>( | |||||||
|   options: ShortcutOptions<T>[], |   options: ShortcutOptions<T>[], | ||||||
| ): ActionReturn<ShortcutOptions<T>[]> => { | ): ActionReturn<ShortcutOptions<T>[]> => { | ||||||
|   function onKeydown(event: KeyboardEvent) { |   function onKeydown(event: KeyboardEvent) { | ||||||
|     const ignoreShortcut = shouldIgnoreShortcut(event); |     const ignoreShortcut = shouldIgnoreEvent(event); | ||||||
|     for (const { shortcut, onShortcut, ignoreInputFields = true, preventDefault = true } of options) { |     for (const { shortcut, onShortcut, ignoreInputFields = true, preventDefault = true } of options) { | ||||||
|       if (ignoreInputFields && ignoreShortcut) { |       if (ignoreInputFields && ignoreShortcut) { | ||||||
|         continue; |         continue; | ||||||
|  | |||||||
| @ -1,11 +1,12 @@ | |||||||
| <script lang="ts"> | <script lang="ts"> | ||||||
|   import { fade } from 'svelte/transition'; |  | ||||||
|   import ImmichLogo from './immich-logo.svelte'; |  | ||||||
|   import { page } from '$app/stores'; |   import { page } from '$app/stores'; | ||||||
|  |   import { shouldIgnoreEvent } from '$lib/actions/shortcut'; | ||||||
|   import { dragAndDropFilesStore } from '$lib/stores/drag-and-drop-files.store'; |   import { dragAndDropFilesStore } from '$lib/stores/drag-and-drop-files.store'; | ||||||
|   import { fileUploadHandler } from '$lib/utils/file-uploader'; |   import { fileUploadHandler } from '$lib/utils/file-uploader'; | ||||||
|   import { isAlbumsRoute, isSharedLinkRoute } from '$lib/utils/navigation'; |   import { isAlbumsRoute, isSharedLinkRoute } from '$lib/utils/navigation'; | ||||||
|   import { t } from 'svelte-i18n'; |   import { t } from 'svelte-i18n'; | ||||||
|  |   import { fade } from 'svelte/transition'; | ||||||
|  |   import ImmichLogo from './immich-logo.svelte'; | ||||||
| 
 | 
 | ||||||
|   $: albumId = isAlbumsRoute($page.route?.id) ? $page.params.albumId : undefined; |   $: albumId = isAlbumsRoute($page.route?.id) ? $page.params.albumId : undefined; | ||||||
|   $: isShare = isSharedLinkRoute($page.route?.id); |   $: isShare = isSharedLinkRoute($page.route?.id); | ||||||
| @ -29,7 +30,13 @@ | |||||||
|     await handleDataTransfer(e.dataTransfer); |     await handleDataTransfer(e.dataTransfer); | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const onPaste = ({ clipboardData }: ClipboardEvent) => handleDataTransfer(clipboardData); |   const onPaste = (event: ClipboardEvent) => { | ||||||
|  |     if (shouldIgnoreEvent(event)) { | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return handleDataTransfer(event.clipboardData); | ||||||
|  |   }; | ||||||
| 
 | 
 | ||||||
|   const handleDataTransfer = async (dataTransfer?: DataTransfer | null) => { |   const handleDataTransfer = async (dataTransfer?: DataTransfer | null) => { | ||||||
|     if (!dataTransfer) { |     if (!dataTransfer) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user