Page MenuHomePhabricator

Reference list <div> can overlap a template <div> because that's how HTML works
Open, LowPublic8 Estimated Story Points

Description

Recently there is a problem when edditing an article, which has a block of refernece list, that the reference list overlaps the block off infobox as displayed at the screenshot. It happens when you open such page to edit:
https://cs.wikipedia.org/wiki/Štičí

ticí.jpg (670×1 px, 96 KB)

and accidently drive your cursor passing by the references and than to infobox area. It hightlights reflist and than once you click in reference area to the taxobox to edit it. You are not opening infobox template, but ref list. I think this might be confusing and basicaly blocks should not overlap eachother.

Event Timeline

Juandev raised the priority of this task from to Needs Triage.
Juandev updated the task description. (Show Details)
Juandev subscribed.
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

There's not much that can be done about this. The HTML box model says that they do indeed overlap, it's just the text flow algorithm that stops them colliding.

The only way to stop them colliding would be:

  • Use display:table instead of block, but this would likely cause more unforseen problems. We try not to restyle elements as much as possible.
  • Calculate the highlights based on text content. This would be very slow, and potentially ugly.
Jdforrester-WMF renamed this task from Reference div overlaps Infobox div to Reference list <div> can overlap a template <div> because that's how HTML works.Jun 8 2016, 12:03 PM
Jdforrester-WMF triaged this task as Low priority.
Jdforrester-WMF set the point value for this task to 8.
Jdforrester-WMF set Security to None.

I think we could notably improve 99% of the cases here by just having some extra handling for Focusable nodes that are outside of normal flow (absolutely positioned or floated, "out-of-flow").

Basically, pre-calculate focusable highlights for out-of-flow nodes (there should not be very many, even https://en.wikipedia.org/wiki/Barack_Obama only has about 60, see test function below), then when displaying any focusable highlights for a node in-flow, mask/subtract the out-of-flow highlights (this might require T190226 first).

A references list colliding with an infobox is the most common case, but this can also happen with e.g. block-template/gallery colliding with e.g. image/mapframe.


Function to determine whether a DOM element is out-of-flow, per the "cheatsheet" at https://www.w3.org/TR/CSS22/visuren.html#dis-pos-flo:

$('.ve-ce-surface *:not(.oo-ui-iconElement-icon)').filter(function isOutOfFlow(i, elem){
	var
		display = $(elem).css('display'),
		position = $(elem).css('position'),
		float = $(elem).css('float');
	if ( display === 'none' ) return false;
	if ( position === 'absolute' || position === 'fixed' ) return true;
	if ( float !== 'none' ) return true;
	return false;
})

(I'm not working on this right now, but I'd like to investigate it soon)

This task had recent discussion.

I think we could notably improve 99% of the cases here by just having some extra handling for Focusable nodes that are outside of normal flow (absolutely positioned or floated, "out-of-flow").

FYI doing computed CSS is very slow, so would need to be done on an on-hover basis, not for all templates on the page on load.