Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: crash when using TouchBarScrubber arrow button #30681

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/touch-bar-scrubber.md
Expand Up @@ -15,7 +15,7 @@ _This class is not exported from the `'electron'` module. It is only available a
* `highlightedIndex` Integer - The index of the item the user touched.
* `selectedStyle` String (optional) - Selected item style. Can be `background`, `outline` or `none`. Defaults to `none`.
* `overlayStyle` String (optional) - Selected overlay item style. Can be `background`, `outline` or `none`. Defaults to `none`.
* `showArrowButtons` Boolean (optional) - Defaults to `false`.
* `showArrowButtons` Boolean (optional) - Whether to show arrow buttons. Defaults to `false` and is only shown if `items` is non-empty.
* `mode` String (optional) - Can be `fixed` or `free`. The default is `free`.
* `continuous` Boolean (optional) - Defaults to `true`.

Expand Down
5 changes: 4 additions & 1 deletion shell/browser/ui/cocoa/electron_touch_bar.mm
Expand Up @@ -735,7 +735,10 @@ - (void)updateScrubber:(NSCustomTouchBarItem*)item

bool showsArrowButtons = false;
settings.Get("showArrowButtons", &showsArrowButtons);
scrubber.showsArrowButtons = showsArrowButtons;
// The scrubber will crash if the user tries to scroll
// and there are no items.
if ([self numberOfItemsForScrubber:scrubber] > 0)
scrubber.showsArrowButtons = showsArrowButtons;

std::string selectedStyle;
std::string overlayStyle;
Expand Down