UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SwiftUI: How do you restore a collapsed sidebar on macOS?

Forums > SwiftUI

Using Apple's Fruta example from WWDC, I've collapsed the sidebar I can't find a way to restore it (via code, UI, keyboard shortcut, or even a fresh build).

Does anyone know of a way to get the sidebar back?

4      

yea it isnt the desired behavior. you can probably add a keyboard shortcut to set the sidebar back to its idealWidth. I am not at a computer right now so I cant try it Another option is to add a minimum width of 10 or something and display a button of some sorts to allow isers to reopen it.

in the meantime running "defaults delete com.youridentifier.yourapp" in a terminal will reset the application.

Edit: This doesn't appear to be the desired behavior in macOS at all. Most apps that have sidebars don't allow the sidebar to be collapsed and reopened by grabbing the side of the screen. XCode, Notes, etc have toolbar icons and keyboard shortcuts to reopen side menus. What you can do is add SidebarCommands() to the .commands of the WindowGroup. That will enable you to toggle the sidebar.

4      

Thx @klheard for the cmd line fix.

Like @stuartbrekenridge, I ran into the missing sidebar in Apple SwiftUI Tutorial - Creating MacOS App. I was going nuts looking for what I messed up in the code. ;-)

Update: In the next section of the Apple SwiftUI Tutorial, they cover this situation. LOL! --> Apple SwiftUI Tutorial - Built in Menu Command

3      

Very very thanks. I lost 48 hours when my app begun crash after i was set wrong language settings.

And your sample is very light and super

3      

I found this article extremely helpful.

2      

Ugh so much for sane defaults. Thanks for links.

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.