Fix toolbar buttons not dispatching when editor has focus#496
Merged
schuyler merged 2 commits intoJul 1, 2026
Merged
Conversation
Standalone toolbar buttons and dropdown menu items set target = self.document during init, but the weak IBOutlet isn't connected until after init, leaving target nil. Actions then went through the responder chain, which worked from the preview pane but failed from the editor pane. Route standalone and dropdown items through the toolbar controller (matching the pattern already used for grouped items), dispatching to self.document at invocation time when the outlet is connected. Related to #278
Dropdown menu items now target the toolbar controller with a generic dropdownMenuItemClicked: action, so MPDocument's validateUserInterfaceItem: can no longer identify them by action selector. Forward validation by temporarily restoring the real action (from representedObject) before calling the document's validation. Related to #278
Contributor
Code Coverage ReportCurrent Coverage: 63.11% Coverage Details (Summary) |
schuyler
added a commit
that referenced
this pull request
Jul 1, 2026
## Summary - Standalone toolbar buttons and dropdown menu items set `target = self.document` during `init`, but the weak IBOutlet isn't connected until after init — leaving target nil. Actions went through the responder chain, which worked from the preview pane but failed from the editor pane. - Route standalone and dropdown items through the toolbar controller (matching the pattern already used for grouped items via `selectedToolbarItemGroupItem:`), dispatching to `self.document` at invocation time when the outlet is connected. - Add `validateUserInterfaceItem:` forwarding on the toolbar controller so dropdown menu items (Layout) still get dynamic titles and enable/disable state from the document. ## Test plan - [x] 13 new unit tests covering standalone and dropdown dispatch, action mapping correctness, and crash-freedom for edge cases - [x] All 1039 tests pass (0 unexpected failures) - [x] Manual: focus editor pane → click Insert Table → table appears - [x] Manual: Layout dropdown shows correct titles (Hide/Restore Editor/Preview Pane) - [ ] CI passes Related to #278
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
target = self.documentduringinit, but the weak IBOutlet isn't connected until after init — leaving target nil. Actions went through the responder chain, which worked from the preview pane but failed from the editor pane.selectedToolbarItemGroupItem:), dispatching toself.documentat invocation time when the outlet is connected.validateUserInterfaceItem:forwarding on the toolbar controller so dropdown menu items (Layout) still get dynamic titles and enable/disable state from the document.Test plan
Related to #278