Page MenuHomePhorge

Tab Panel: the first Tab is not always auto-selected anymore
Closed, ResolvedPublic

Description

As you can see from this snapshot in Internet Archive, it can happen that a Tab Panel is never opened as default:

https://web.archive.org/web/20231005061247/https://phabricator.wikimedia.org/W6

Tab Panel unselected.png (142×488 px, 6 KB)

As workaround, you always need to click on a tab to show something.

What should happen instead:

The first tab should always be open as default. Example:

https://web.archive.org/web/20200102154343/https://phabricator.wikimedia.org/W6

As it happened to be opened as default, before this change:

rPcbc0e661544a: Change erroneous loose comparison to strict comparison in tab panels

Possible cause

It seems there was this loose check, relying on ($idx == $selected) and so with (0 == 'kq3p37awi2n5') that is evaluated to true, so that the first one was automatically selected:

$content[] = phutil_tag(
  'div',
  array(
    'id' => $content_id,
    'style' => ($idx == $selected) ? null : 'display: none',

Possible solution

If nothing was automatically selected, we should handle this case differently.

So, in that case, we should just pick the first element, without comparing IDs.

We should probably also continue to do strict checks, to highlight the root problem in the future. Since this is the 3rd follow-up edit on this file for similar problems.


Reported from Wikimedia Phabricator (now using Phorge):

https://phabricator.wikimedia.org/T344835