From cbc0e661544a31290099ab3d88481bb8d4a3003c Mon Sep 17 00:00:00 2001 From: dylsss Date: Fri, 2 Jun 2023 15:16:33 +0200 Subject: [PATCH] Change erroneous loose comparison to strict comparison in tab panels Summary: Fix a loose comparison causing a bug when comparing the selected tab (0) with a tab which has an alphanumeric ID which doesn't begin with an integer. E.g., `(0 == 'kq3p37awi2n5')` is true in PHP 7.4 and below, this can sometimes cause multiple tabs to be displayed when a tab panel is first loaded onto a page: {F278735} Test Plan: Create a tab panel with at least 3 tabs, add a couple more and ensure that multiple tabs aren't loaded. Reviewers: O1 Blessed Committers, valerio.bozzolan, Cigaryno, avivey Reviewed By: O1 Blessed Committers, valerio.bozzolan, Cigaryno, avivey Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15146 Differential Revision: https://we.phorge.it/D25067 --- .../paneltype/PhabricatorDashboardTabsPanelType.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardTabsPanelType.php b/src/applications/dashboard/paneltype/PhabricatorDashboardTabsPanelType.php index 91c6d17833..54c26dd9d3 100644 --- a/src/applications/dashboard/paneltype/PhabricatorDashboardTabsPanelType.php +++ b/src/applications/dashboard/paneltype/PhabricatorDashboardTabsPanelType.php @@ -111,9 +111,11 @@ final class PhabricatorDashboardTabsPanelType $name = pht('Unnamed Tab'); } + $is_selected = (string)$idx === (string)$selected; + $tab_view = id(new PHUIListItemView()) ->setHref('#') - ->setSelected((string)$idx === (string)$selected) + ->setSelected($is_selected) ->addSigil('dashboard-tab-panel-tab') ->setMetadata(array('panelKey' => $idx)) ->setName($name); @@ -286,7 +288,7 @@ final class PhabricatorDashboardTabsPanelType 'div', array( 'id' => $content_id, - 'style' => ($idx == $selected) ? null : 'display: none', + 'style' => $is_selected ? null : 'display: none', ), $panel_content); -- 2.51.2