From 2d635fb76e9b20cce53ed68fe1dfd4daa79aa8c2 Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Mon, 16 Oct 2023 08:40:23 +0200 Subject: [PATCH] Dashboard Panel: fix first tab sometime not opened anymore Summary: After this change the first Tab ID is always selected, so we don't risk to have no tabs opened by default under some corner cases. This is vaguely better than the original logic that relied on the fact that (0=="0") is true. Besides being a vaguely weird emoticon as well, now that I look at it better. Original logic: https://we.phorge.it/source/phorge/browse/master/src/applications/dashboard/paneltype/PhabricatorDashboardTabsPanelType.php;c43618a3a8bb021936fad687f04cb1a95faa23e4$289 This fixes a regression that appeared in the cute Wikimedia Phabricator (that now is really Wikimedia Phorge). Their homepage should be gorgeous again, without blank space due to unopened silly tabs. Closes T15651 Test Plan: - Have a Tab Panel (/dashboard/panel/). - Be sure that the first Tab is automatically selected (again?) Reviewers: aklapper, O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15651 Differential Revision: https://we.phorge.it/D25447 --- .../paneltype/PhabricatorDashboardTabsPanelType.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardTabsPanelType.php b/src/applications/dashboard/paneltype/PhabricatorDashboardTabsPanelType.php index 3cf73b539e..6b4f2fe5d6 100644 --- a/src/applications/dashboard/paneltype/PhabricatorDashboardTabsPanelType.php +++ b/src/applications/dashboard/paneltype/PhabricatorDashboardTabsPanelType.php @@ -85,10 +85,12 @@ final class PhabricatorDashboardTabsPanelType $rename_uri = id(new PhutilURI($rename_uri)) ->replaceQueryParam('contextPHID', $context_phid); - $selected = 0; - $key_list = array_keys($config); + // In the future we may persist which panel was selected. + // At the moment we have always selected the first one. + $selected = (string)head($key_list); + $next_keys = array(); $prev_keys = array(); for ($ii = 0; $ii < count($key_list); $ii++) { @@ -111,7 +113,8 @@ final class PhabricatorDashboardTabsPanelType $name = pht('Unnamed Tab'); } - $is_selected = (string)$idx === (string)$selected; + // The $idx can be something like "0", "1" or "asdasd98". + $is_selected = (string)$idx === $selected; $tab_view = id(new PHUIListItemView()) ->setHref('#') @@ -282,7 +285,8 @@ final class PhabricatorDashboardTabsPanelType $panel_content = pht('(Invalid Panel)'); } - $is_selected = (string)$idx === (string)$selected; + // Note that $idx can be something like "0", "1" or "asdasd98". + $is_selected = (string)$idx === $selected; $content_id = celerity_generate_unique_node_id();