Page MenuHomePhabricator

Don't create random ids for sections
Closed, ResolvedPublic

Description

I'm just catching up and saw the solution to T88473. I don't think it should be done this way and seems like a hacky way to fix the problem.

This is not good - an id really should be meaningful and should be consistent for different users/different sessions or it shouldn't be used at all.
Please revisit this restoring collapsible-block-1 etc.. and instead prefix these e.g. toc-collapsible-block-1, page-collapsible-block-1

On a side note, this has already created issues with the browser tests.

Event Timeline

Jdlrobson raised the priority of this task from to Needs Triage.
Jdlrobson updated the task description. (Show Details)
Jdlrobson moved this task to Incoming on the Web-Team-Backlog-Archived board.
Jdlrobson subscribed.

I think index isn't helpful here because of the risk of a false positive when the test should fail

Where are 'toc' and 'page' prefixes coming from? IDs of the container? If so, there is no guarantee that the container has an ID. Any other suggestions how to change this?

Well toggle.enable currently takes a container. It could also take a prefix.

How do you guarantee that prefixes are unique? Who keeps track of them? I don't think it's a good solution.

I really don't understand your question - the prefixes are unique because they are fixed in our code.

Math.random()
'foo'

the second is static, the first isn't.

Change 192858 had a related patch set uploaded (by Jdlrobson):
Don't use random ids for toggleable sections

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

Change 192858 merged by jenkins-bot:
Don't use random ids for toggleable sections

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