You are browsing as a guest. Sign up (or log in) to start making projects!

2h 7m 49s logged

Creating, renaming, and deleting files/folders!

This one took a hot minute but it works really great! It’s so much better than using a modal to do everything!

I didn’t actually know this but the tree component has support for creating files like this out of the box, it’s just not listed in any documentation so it took me a bit to find. It actually starts by creating a file named “New File”, then just immediately renaming it, which is a much cleaner solution than what I was planning :yay:

Renaming is painfully simple, as it handles a bunch of the work too but it’s actually a completely different component it changes to when you start renaming, which ended up being so much easier to work with.

I ran into one of the stupidest bugs ever while implementing renaming. The best way to describe it is “When renaming a file, if it is the open tab, whenever it autosaves it will reset the rename input cause it rerenders.” But basically, the autosaver would save the selected file, causing everything that uses useEditor to rerender, including the sidebar, which makes it re-render the input component for renaming, which resets the text to it’s initialName. It wasn’t hard to fix, I just made the autosaver not save if the content hasn’t changed, which I’ve been meaning to do anyway.

For now, that is most of the hard features done :yayayayayay: the last hurdle that I’m not excited to implement is links between pages. I have no clue how that will work, especially with the component I’m using. But that’s next!

0
3

Comments 0

No comments yet. Be the first!