Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 2fd8234498119dd0369e13d87c7d7512b6d785be https://github.com/WebKit/WebKit/commit/2fd8234498119dd0369e13d87c7d7512b6d785be Author: Qianlang Chen <qianlangc...@apple.com> Date: 2024-02-28 (Wed, 28 Feb 2024)
Changed paths: M Source/WebInspectorUI/UserInterface/Views/ScopeBar.js Log Message: ----------- Fix Web Inspector: WI.ScopeBar.Event.SelectionChanged is fired four times whenever selecting an item (242705) https://bugs.webkit.org/show_bug.cgi?id=242705 rdar://96963052 Reviewed by Devin Rousso. The bug report refers to an issue that happens with the components ScopeBar and MultipleScopeBarItem, which is used across multiple places in the inspector's frontend. This commit fixes the issue for both components, such that the event `ScopeBar.Event.SelectionChanged` is always only fired once, no matter whether MultipleScopeBarItem is involved (like in the Sources tab) or not (like in the Console tab). However, the solution to solving the bug for either component is independent and different: - The class MultipleScopeBarItem already does well to suppress multiple echos of the SelectionChanged event with the help of `_ignoreItemSelectedEvent` (see https://github.com/WebKit/WebKit/blob/6d51d579af47028306a003653150ade5d395f942/Source/WebInspectorUI/UserInterface/Views/MultipleScopeBarItem.js#L211-L212) However, in the original code, ScopeBar did not make use of this benefit and still listens to SelectionChanged from the individual items. When MultipleScopeBarItem is used, this commit makes ScopeBar listen to MultipleScopeBarItem instead. - When MultipleScopeBarItem is not used, ScopeBar in the original code did not do anything to protect against echos (i.e. events caused by the ScopeBar itself as a result of deselecting its ScopeBarItems). This commit mimics the fix from MultipleScopeBarItem and introduces the same boolean flag to bypass echos caused by the ScopeBar itself. * Source/WebInspectorUI/UserInterface/Views/ScopeBar.js: (WI.ScopeBar.prototype._populate): - Listen to SelectionChanged events from MultipleScopeBarItem instead of the individual ScopeBarItems. (WI.ScopeBar.prototype._itemSelectionDidChange): - Guard against echos by ignoring events caused by `item.selected = ...` statements within the handler itself. - Rewrite the deselecting logic to be more readable. Canonical link: https://commits.webkit.org/275435@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes