mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-17 08:21:12 -05:00
[PR #15093] [MERGED] fix: refine folder component's drag-&-drop error handling #46761
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/15093
Author: @silentoplayz
Created: 6/18/2025
Status: ✅ Merged
Merged: 6/18/2025
Merged by: @tjbck
Base:
dev← Head:fix-sidebar-drag-and-drop📝 Commits (1)
b120637fix: refine folder component's drag-&-drop error handling📊 Changes
1 file changed (+17 additions, -7 deletions)
View changed files
📝
src/lib/components/common/Folder.svelte(+17 -7)📄 Description
Pull Request Checklist
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
Foldercomponent (e.g., in the chat sidebar) would lead toSyntaxError: JSON.parse: unexpected characterbeing logged in the console. Although the error was caught and didn't crash the application, the changes refine the drag-and-drop handling to gracefully ignore non-JSONtext/plaindata without logging errors, improving the developer experience.Changed
onDropevent handler inFolder.svelteto specifically handle cases wheree.dataTransfer.getData('text/plain')might not be valid JSON or might be empty.console.errortoconsole.logfor expectedSyntaxErrorwhen droppedtext/plaindata is not JSON, reducing console noise for non-pertinent drops.if (dataTransfer)before attemptingJSON.parseto prevent parsing empty strings.draggedOverstate is consistently reset tofalsein the non-file drop path, regardless of parsing success or failure.folderElement.addEventListener('dragover', onDragOver);changed tofolderElement.removeEventListener('dragover', onDragOver);.Fixed
SyntaxError: JSON.parse: unexpected characterwas logged in the console when non-JSON data was dropped onto theFoldercomponent. The component now gracefully handles such drops without error logs.Additional Information
text/plainJSON data are processed.draggedOvernot always being reset, although the primary focus of this PR is console noise. ThedraggedOverreset logic was also improved.Screenshots or Videos
Browser console error (before fix applied):

Lighter gray area in chat sidebar (before fix applied):

Browser console.log (after fix applied):
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.