FelixKratz / SketchyBar

A highly customizable macOS status bar replacement
https://felixkratz.github.io/SketchyBar/
GNU General Public License v3.0
6.39k stars 95 forks source link

Issue with moving items between popup menus #615

Closed Capybara121 closed 1 week ago

Capybara121 commented 1 month ago

Description

When attempting to move items between different popup menus, items do not move back correctly (exact nature of behaviour unknown)

Code

test.lua
``` item1 = sbar.add("item","item1",{ popup = {drawing = true} }) item2 = sbar.add("item","item2",{ popup = {drawing = true} }) member1 = sbar.add("item","member1",{ label = "member1", position = "popup.item1" }) member2 = sbar.add("item","member2",{ label = "member2", position = "popup.item2" }) member1:set({position = "popup.item2"}) member1:set({position = "popup.item1"}) ```

Behaviour

Expected behaviour: Item should move to one menu, then move back to its original menu.

Screenshot 2024-09-21 at 7 17 54 PM

Actual behaviour: Item is moved to one menu and remains in said menu.

Screenshot 2024-09-21 at 7 16 46 PM

Capybara121 commented 1 month ago

Turns out the issue was that when an item has its position changed via bar_item_set_position, it never actually removes itself from the popup that it was added in, meaning that when you attempt to move it back it will not be able to be moved back due to the condition of popup_add_item not allowing an item to be added if the item already exists. Will be posting a PR shortly.

Capybara121 commented 1 month ago

Not entirely sure whether this warrants a reopening of this issue or a new issue to be made, but I found some more potential problems as follows:

https://github.com/user-attachments/assets/022a0ebf-574b-4299-8656-daf2fb26545f