NSToolbarItemGroup dynamically update subitems in toolbar

Developing on Monterey 12.7.5

I'm having trouble with updating subitems on NSToolbarItemGroup when selecting the item directly from the NSToolbar items array.

I select the group item off the items array on the toolbar, and then call setSubitems: on the item, with a new array of NSToolbarItems. The group item disappears from the toolbar. It seems to leave a blank invisible item in the toolbar taking up space. I can't manually reinsert the item into the toolbar until I drag out the blank item, then drag back in the real item. Once dragged back in from the palette it displays correctly.

The workaround I've come up with is to remove the item with NSToolbar removeItemAtIndex: and reinsert it with NSToollbar insertItemWithItemIdentifier:atIndex:. This works to update the subitems.

Every other toolbar item property that I've tried has been able to update the item directly in the toolbar. It's only the group item's subitems that don't want to update correctly.

Is there a correct way to do this that I'm missing? Calling [toolbar validateVisibleItems] didn't seem to help.

NSToolbarItemGroup dynamically update subitems in toolbar
 
 
Q