-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand <details> for find-in-page and element fragments #6466
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty solid now. Thanks for reminding me about how details is specified in terms of shadow trees already.
In particular, the way in which it's specified ("The details element's second slot is expected to be removed from the rendering when the details element does not have an open attribute.") means that what you've done here is just about as rigorous as that section already is, so I'm happy.
We've got some editorial work to do on the revealing algorithm, starting refactoring from gotos to loops, but that's relatively easy. I'll resolve our previous discussions as I think we're on a clear road to success here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, but there's a number of style issues to be finished.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! @annevk might want to take a final look.
Now we just need tests. The fragment navigation case is definitely testable using web platform tests.
The find-in-page case, I'm not so sure. Maybe it's testable using window.find()
? But that's nonstandard so I'm not sure what to think about that. It'd be worth trying to add a tentative test using window.find()
and see if it works; if not then oh well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we don't have find-in-page itself defined in enough detail to know what kind of tasks it queues? If we ever add an API there it would be good to ensure the timing between that and these events here are solid.
source
Outdated
@@ -76140,6 +76167,25 @@ body { display:none } | |||
can navigate through the <span data-x="fip-matches">matches</span> by advancing the <span | |||
data-x="fip-active-match">active match</span> using the <span>find-in-page interface</span>.</p> | |||
|
|||
<p>When find-in-page begins searching for matches, all <code>details</code> elements in the page | |||
which are not <code data-x="attr-details-open">open</code> should have their second slot be added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "which do not have their open attribute set"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thanks!
source
Outdated
to the rendering without modifying the <code data-x="attr-details-open">open</code> attribute. | ||
After find-in-page finishes searching for matches, those <code>details</code> elements should have | ||
their second slot be removed from the rendering again. This entire process must happen | ||
synchronously (and so is not observable to users or to author code).</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to use "act as if" here as the exact implementation strategy does not matter, as long as you can search through them. That might also allow for removal of the final sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for as-if, but I think the final sentence is still pretty important for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added "act as if", and I also said that it is to make sure the slot can be searched by find-in-page. How does it look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see "act as if" in the spec text?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the following steps:</p> | ||
|
||
<ol> | ||
<li><p>Let <var>node</var> be the first node in the <span data-x="fip-active-match">active |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: single-space indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
The timing is already important for scrolling - the details revealing algorithm must run before find-in-page scrolls to the active match. |
Yeah. I wonder if @zcorpan or @whatwg/css has insights on that as CSSOM View does attempt to define scrolling. |
So I'm a bit concerned about the way this is defined, because the "acts as" implies that you actually need to create boxes for the I would've thought that the way we'd define this would allow for some false positives. The way I would go about implementing something like this would be to do a search on the DOM, and if that might match then open the element. It'd open the element in cases where there might be no match like: <details>
<span hidden>text that if searched for would open the details element, but then not match after all</span>
</details> The alternative to that would be opening all details elements on the page, but that seems potentially more annoying to users... Curious, how were you planning on implementing this @josepharhar? (Just in case I've missed something obvious or what not) |
Thanks for pointing out this event case!
I was also very disappointed when working on this feature when I found out that we have to run layout in order to do searching instead of just relying on the DOM. However, in the
Since you asked, I'll explain everything :) The way I'm implementing this in chrome does three things with regards to find-in-page:
|
source
Outdated
<li><p><span data-x="concept-element-attributes-set-value">Set</span> the <code | ||
data-x="attr-details-open">open</code> attribute on <var>currentNode</var> to the empty | ||
string.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better for this step to do nothing if the open
attribute is already set (the value could be something other than the empty string)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I added some text in this sentence to account for this.
CSSOM View says this for scrolling: https://drafts.csswg.org/cssom-view/#scrolling-events and "run the scroll steps" is called from https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering The effect of that is only about when and where to fire |
And https://drafts.csswg.org/cssom-view/#scroll-an-element-into-view which is used by https://html.spec.whatwg.org/multipage/interaction.html#find-in-page says, only as a non-normative statement of fact, "It is highlighted and scrolled into view." -- the new algorithm added in this PR could formalize the scrolling into view for find-in-page. The sequential focus navigation section doesn't say to scroll into view, only running the focusing steps (which also don't say to scroll into view, as far as I can tell). |
@emilio do you have any thoughts on my last comments? Is there anything left? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable, modulo the bit below which I think needs fixing...
It seems this should be testable at least with window.find()
?
Supporting window.find() for hidden=until-found/content-visibility:hidden-matchable (and for this feature) was something that never fully got resolved... |
It might be worth landing some |
Thanks! @emilio and/or @annevk could you approve? (I'm guessing that is needed to merge this...?)
I'd be happy to modify these tests to use window.find for this feature and make them WPTs:
|
We just talked about also testing the use of content-visibility inside |
I pushed a commit with some minor editorial tweaks., and added a note explaining the style attribute thing. Would you be able to take a final look at that commit, @josepharhar, to confirm my changes were good? After that, what remains is to file browser bugs, then we can merge. |
Thanks, looks great!
Here is a WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=228843 |
Addresses #4051
/browsing-the-web.html ( diff )
/index.html ( diff )
/infrastructure.html ( diff )
/interaction.html ( diff )
/interactive-elements.html ( diff )
/references.html ( diff )
/rendering.html ( diff )