1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

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
This commit is contained in:
dylsss 2023-06-02 15:16:33 +02:00 committed by Valerio Bozzolan
parent 6b8ec50148
commit cbc0e66154

View file

@ -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);