-
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
delegatesFocus interacts poorly with CSS scroll-margin #7033
Comments
Is this an issue specific to delegatesFocus though? How does normal scrolling avoid this issue? |
What do you mean with normal scrolling? This is because of the scrollIntoView call that focusing implicitly does. When calling scrollIntoView on something, you use the scroll-margin set on that thing. |
So this is an issue with scrollIntoView right, not necessarily just focus? |
Well, sorta, I guess? When you |
Perhaps
The effective i.e., <!doctype html>
<style>
body { margin: 0 }
.padding {
height: 400vh;
}
.margin {
scroll-margin-top: 100px;
}
#content {
background-color: green;
width: 100px;
height: 100px;
}
</style>
<a href="#content">Scroll</a>
<div class="padding"></div>
<div class="margin">
<div class="margin" id="content"></div>
</div>
<div class="padding"></div> @tabatkins @fantasai I wonder why scroll-margin wasn't defined to accumulate using ancestor boxes, like regular margin is? I guess it does make the implementation quite a bit trickier, but seems to me that'd be a more sensible behavior? |
The way delegatesFocus is implemented means that some css properties like e.g. scroll-margin don't work as authors expect. When I do something like:
And
my-component
delegates focus to something inside its shadow tree, I'd expectmyComponent.focus()
to honor that scroll margin. However we'd only look at the scroll margin of the scrolled-to element, which would be the delegated element (and which would havescroll-margin
set to all zeros).The component would have to explicitly inherit through scroll-margin, which seems bad? Perhaps
scroll-margin
should be inherited? Perhaps we should look atscroll-margin
on shadow hosts and add it to the children scroll margin? Perhaps something else?This came up because Firefox uses something somewhat similar to
delegatesFocus
(but hackier) in<input type=date>
and somebody reported this bug.cc @sefeng211 @whatwg/css @whatwg/components
The text was updated successfully, but these errors were encountered: