From f746c7bdf2d111d8a169a6d6fa80e77f2def78f9 Mon Sep 17 00:00:00 2001 From: Coding On Star <447357187@qq.com> Date: Thu, 23 Apr 2026 11:03:20 +0800 Subject: [PATCH] fix(plugin): handle file input reset and improve local installer close functionality (#35506) Co-authored-by: CodingOnStar --- .../install-plugin-dropdown.spec.tsx | 2 ++ .../plugin-page/install-plugin-dropdown.tsx | 26 ++++++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/web/app/components/plugins/plugin-page/__tests__/install-plugin-dropdown.spec.tsx b/web/app/components/plugins/plugin-page/__tests__/install-plugin-dropdown.spec.tsx index 6d6784dea8..9f883af1b2 100644 --- a/web/app/components/plugins/plugin-page/__tests__/install-plugin-dropdown.spec.tsx +++ b/web/app/components/plugins/plugin-page/__tests__/install-plugin-dropdown.spec.tsx @@ -199,6 +199,7 @@ describe('InstallPluginDropdown', () => { const { container } = render() fireEvent.click(screen.getByTestId('dropdown-trigger')) + fireEvent.click(screen.getByText('plugin.source.local')) fireEvent.change(container.querySelector('input[type="file"]')!, { target: { files: [new File(['content'], 'plugin.difypkg')], @@ -235,6 +236,7 @@ describe('InstallPluginDropdown', () => { const { container } = render() fireEvent.click(screen.getByTestId('dropdown-trigger')) + fireEvent.click(screen.getByText('plugin.source.local')) fireEvent.change(container.querySelector('input[type="file"]')!, { target: { files: [new File(['content'], 'plugin.difypkg')], diff --git a/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx b/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx index f74de31159..a972c9891c 100644 --- a/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx +++ b/web/app/components/plugins/plugin-page/install-plugin-dropdown.tsx @@ -49,7 +49,8 @@ const InstallPluginDropdown = ({ }) const handleFileChange = (event: React.ChangeEvent) => { - const file = event.target.files?.[0] + const file = event.target.files?.[0] ?? null + event.target.value = '' if (file) { setSelectedFile(file) setSelectedAction('local') @@ -57,6 +58,13 @@ const InstallPluginDropdown = ({ } } + const handleCloseLocalInstaller = () => { + setSelectedAction(null) + setSelectedFile(null) + if (fileInputRef.current) + fileInputRef.current.value = '' + } + // TODO TEST INSTALL : uninstall // const [pluginLists, setPluginLists] = useState([]) // useEffect(() => { @@ -105,6 +113,13 @@ const InstallPluginDropdown = ({ return (
+ {t('installFrom', { ns: 'plugin' })} - {installMethods.map(({ icon: Icon, text, action }) => ( setSelectedAction(null)} + onClose={handleCloseLocalInstaller} onSuccess={noop} /> )}