Page MenuHomePhabricator

Collapsible elements are invisible to browser search
Closed, ResolvedPublicBUG REPORT

Description

Steps to reproduce

  1. Open https://www.mediawiki.org/w/index.php?title=Manual:Collapsible_elements&oldid=5581603
  2. Using the browser search (+F, +F etc.), search for is hidden.

Actual result

  1. Two results are found, in the two code examples.

Expected result

  1. Four results are found: two in the code examples, and two in the rendered examples.

Other information

At least in Chrome and many Chromium-based browsers, MobileFrontend fixed this in 1abe4bd7dbd3b4001979a9bdb518f8d4d287a485 (T216789). The same fix should work here as well.

Keywords for searchability: collapse, collapsibility, template


Browsers supporting this feature: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/hidden#browser_compatibility

  • Chrome since 102 (and Chromium-based browsers), released in 2022
  • Firefox since 139, released in May 2025

Event Timeline

Change 967556 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/core@master] makeCollapsible: Expand when text is matched with browser find feature

https://gerrit.wikimedia.org/r/967556

Unfortunately this won't work with how we current collapse tables, as content-visibility can't be used to hide table structure, but it will work in all other cases.

Unfortunately this won't work with how we current collapse tables, as content-visibility can't be used to hide table structure, but it will work in all other cases.

I realised we can force this to work with table cells, by turning them into not-table cells when hidden (using display:block)!

matmarex updated the task description. (Show Details)

Change #967556 merged by jenkins-bot:

[mediawiki/core@master] makeCollapsible: Expand when text is matched with browser find feature

https://gerrit.wikimedia.org/r/967556

@Esanders, probably instead of the specific fix for .wikitable.mw-collapsed, there should be a wider fix for .mw-collapsed [ hidden='until-found' ]. In Russian Wikipedia, we have already found a case with a visible border around a hidden element. I believe there are similar issues in every wiki project.

Change #1166234 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@master] jquery.makeCollapsible: Avoid extra borders etc. on un-rendered elements

https://gerrit.wikimedia.org/r/1166234

@putnik Could you please link some examples, so that we can make sure that this patch will work for them?

Test wiki created on Patch demo by Matma Rex using patch(es) linked to this task:
https://patchdemo.wmcloud.org/wikis/4494d98855/w/

Change #1166234 merged by jenkins-bot:

[mediawiki/core@master] jquery.makeCollapsible: Avoid extra borders etc. on un-rendered elements

https://gerrit.wikimedia.org/r/1166234

Test wiki on Patch demo by ESanders (WMF) using patch(es) linked to this task was deleted:

https://patchdemo.wmcloud.org//wikis/8382623358/w/

These changes basically broke the entire way you could uncollapse collapsible elements via CSS. Instead of the previous way of assigning the display value to hidden CSS, now you need to override all of these properties or to manipulate those elements entirely via JS (which makes FOUC happen):

.mw-collapsible[hidden="until-found"], .mw-collapsible [hidden="until-found"] {
	display: block;
	position: absolute;
	width: 0 !important;
	height: 0 !important;
	overflow: hidden !important;
	padding: 0 !important;
	margin: 0 !important;
	border: 0 !important;
}

Is there reasonably no more reasonable way to do this? I suppose this is a general problem with this CSS spec, but it essentially means that you can no longer unhide the elements hidden with this normally, because it takes 8 properties with differing values as opposed to previous 1 property. Additionally, this change reintroduced FOUC from assigning hidden="until-found" to the elements that was not present in .mw-made-collapsible version.

Test wiki on Patch demo by Matma Rex using patch(es) linked to this task was deleted:

https://patchdemo.wmcloud.org//wikis/4494d98855/w/

These changes basically broke the entire way you could uncollapse collapsible elements via CSS. Instead of the previous way of assigning the display value to hidden CSS, now you need to override all of these properties or to manipulate those elements entirely via JS (which makes FOUC happen):
(…)
Is there reasonably no more reasonable way to do this? I suppose this is a general problem with this CSS spec, but it essentially means that you can no longer unhide the elements hidden with this normally, because it takes 8 properties with differing values as opposed to previous 1 property. Additionally, this change reintroduced FOUC from assigning hidden="until-found" to the elements that was not present in .mw-made-collapsible version.

Sorry… I think this is just how it is. Maybe you could use all: initial (https://caniuse.com/css-all), but that will also reset other styles, which you might not want.

I don't think collapsible elements using mw-collapsible were intended to ever be un-collapsed using CSS – if you do that, won't you also have the toggle buttons displaying wrong text and performing the wrong action? I guess you're hiding them too or something? I really want to say that this is just not supported.

I think you misunderstood what I wrote. I don’t need toggle buttons for elements I am trying to uncollapse (forms on history page etc., certain collapsed elements on wiki pages). I just want to see them uncollapsed. Before, it took a simple CSS declaration to do so. I get that it is more so a problem of CSS specification you’ve used, but still, the resulting reset styles on these elements are pretty annoying to deal with. Having simply all: initial or something would be an improvement, indeed.

Change #1166234 merged by jenkins-bot:

[mediawiki/core@master] jquery.makeCollapsible: Avoid extra borders etc. on un-rendered elements

https://gerrit.wikimedia.org/r/1166234

This change seems to have broken https://en.wikipedia.org/wiki/MediaWiki:Print.css . See report now at https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)/Archive_224#Automatically_expand_everything_collapsible_when_printing_the_page . Removing position: absolute corrects that issue, but I'd also be fine with moving that LESS into a @media screen block thereby dodging any particular question above about the utility of overriding relevant CSS in screen.