CodeEdit icon indicating copy to clipboard operation
CodeEdit copied to clipboard

🐞 Menu Bar Items Not Updating

Open knotbin opened this issue 1 year ago • 3 comments

Description

Menu bar items' text and disabled state do not update unless you exit and reenter window. Menu bar items that should toggle between "Show ___" and "Hide ___" simply stay in their original state until you exit and reenter the window. The same is true for disabled commands that are eligible to enable, but do not until you exit and reenter the window.

To Reproduce

  1. Go to menu bar
  2. Click on View (this is used for example, the bug is present in all menu items)
  3. Click on Hide Navigator/Show Navigator
  4. Click on View again The button will not have changed (from Hide Navigator to show Navigator or vice versa.)
  5. Exit the window by clicking on any other window or your desktop
  6. Re-enter the window
  7. Click on View in the menu bar The button will now have updated

Expected Behavior

When you click on a button - hide navigator for example - it will change states - changing to show navigator - without the need to exit and reenter the window.

Version Information

CodeEdit: [0.2] macOS: [14.4.1] Xcode: [15.3]

Additional Context

No response

Screenshots

https://github.com/CodeEditApp/CodeEdit/assets/118622417/6c62bcde-84f1-4e04-b692-d807a0d64890

knotbin avatar Apr 24 '24 23:04 knotbin

Possible cause: These Command files take in ObservableObjects using @State instead of @StateObject, which would cause the entire view to reload whenever it is changed, rather than @State which does not reload the entire view after changes. Transitioning to using @StateObject may be the solution.

knotbin avatar Apr 24 '24 23:04 knotbin

Hm, just changing

@State var windowController: CodeEditWindowController?

to

@StateObject var windowController: CodeEditWindowController?

Throws an error, since we're applying StateObject to an optional type; is there an elegant workaround for this?

xyzqm avatar Apr 29 '24 15:04 xyzqm

@austincondiff can I be assigned to this issue? I think I should be able to fix #1696 as well, just a few minor tweaks needed

xyzqm avatar May 01 '24 04:05 xyzqm