Skip to content

Commit

Permalink
REGRESSION (iOS 16): <optgroup> labels are duplicated
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=247443
rdar://101241715

Reviewed by Wenson Hsieh.

WebKit displays <optgroup> elements as inline submenus. Prior to iOS 16, UIKit
did not display titles for inline submenus. Consequently, WebKit inserted a
disabled menu item at the top of each submenu, containing the <optgroup>'s
label.

However, UIKit began displaying titles for submenus in iOS 16, resulting in
duplicate labels. To fix, remove the labels added by WebKit.

* Source/WebKit/UIProcess/ios/forms/WKFormSelectPicker.mm:
(-[WKSelectPicker createMenu]):
(-[WKSelectPicker actionForOptionIndex:]):

Canonical link: https://commits.webkit.org/256324@main
  • Loading branch information
pxlcoder committed Nov 4, 2022
1 parent 6a72f93 commit ad03a71
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions Source/WebKit/UIProcess/ios/forms/WKFormSelectPicker.mm
Expand Up @@ -564,12 +564,6 @@ - (UIMenu *)createMenu
NSString *groupText = optionItem.text;
NSMutableArray *groupedItems = [NSMutableArray array];

if (groupText.length) {
UIAction *action = [UIAction actionWithTitle:groupText image:nil identifier:nil handler:^(UIAction *action) { }];
action.attributes = UIMenuElementAttributesDisabled;
[groupedItems addObject:action];
}

currentIndex++;
while (currentIndex < _view.focusedSelectElementOptions.size()) {
auto& childOptionItem = _view.focusedSelectElementOptions[currentIndex];
Expand Down Expand Up @@ -628,10 +622,6 @@ - (UIAction *)actionForOptionIndex:(NSInteger)optionIndex
UIMenu *groupedMenu = (UIMenu *)menuElement;
NSUInteger numGroupedOptions = groupedMenu.children.count;

// The first child of a grouped menu with a title represents the title, and is not a selectable option.
if (groupedMenu.title.length)
numGroupedOptions--;

if (currentIndex + numGroupedOptions <= (NSUInteger)optionIndex)
currentIndex += numGroupedOptions;
else
Expand Down

0 comments on commit ad03a71

Please sign in to comment.