Skip to content

Commit 08fdbfc

Browse files
author
Ignacio Romero Zurbuchen
authored
Merge pull request slackhq#555 from kirb/kirb/fix/empty-format-menu
Do not show the "Format" item if this feature is not being used.
2 parents 38ad6e5 + a18b829 commit 08fdbfc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Source/SLKTextView.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,15 @@ - (void)slk_addCustomMenuControllerItems
740740
{
741741
UIMenuItem *undo = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Undo", nil) action:@selector(slk_undo:)];
742742
UIMenuItem *redo = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Redo", nil) action:@selector(slk_redo:)];
743-
UIMenuItem *format = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Format", nil) action:@selector(slk_presentFormattingMenu:)];
744743

745-
[[UIMenuController sharedMenuController] setMenuItems:@[undo, redo, format]];
744+
NSMutableArray *items = [NSMutableArray arrayWithObjects:undo, redo, nil];
745+
746+
if (self.registeredFormattingTitles.count > 0) {
747+
UIMenuItem *format = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"Format", nil) action:@selector(slk_presentFormattingMenu:)];
748+
[items addObject:format];
749+
}
750+
751+
[[UIMenuController sharedMenuController] setMenuItems:items];
746752
}
747753

748754
- (void)slk_undo:(id)sender

0 commit comments

Comments
 (0)