Fix file state loss on page refresh (#5450)
Fixes
File directory and editor content are lost when refreshing the page while creating a new file. Video: https://imgur.com/PimtXLg (From the original issue thread)
Videos(Fixed)
Video1 : https://imgur.com/a/cWXsI1K Video2 : https://imgur.com/a/IW9aaZV
Closes #5450
Problem
- Refreshing the page during "New File" creation resets the directory to
/ - Typed content in the editor is lost on refresh
Cause
When action === 'new', the directory state was never initialized from the URL hash, causing it to default to /.
Solution
- Properly initialize directory state from the URL hash when creating new files
- Persist unsaved editor content in
localStorageand restore it after refresh - Automatically clear draft content after a successful save
Scope
- Applies only to
action === 'new' - Editing existing files is unaffected
Testing
- Create new file in subdirectory → refresh → save → file stays in correct directory
- Editor content is restored after refresh
- Draft is cleared after saving
Important
- doesn't chnage anything in backend all changes are frontend/UI only so no major rework is needed
(ignore)
wdym?
(ignore)
wdym?
It was because of my message. I didn't remember that it could be deleted
It was because of my message. I didn't remember that it could be deleted
any idea on how long would it take for the checks to be started all are currently in pending state
It was because of my message. I didn't remember that it could be deleted
any idea on how long would it take for the checks to be started all are currently in pending state
"This workflow is awaiting approval from a maintainer in https://github.com/pterodactyl/panel/pull/5480"