Re: [csswg-drafts] [css-position-3] Reinterpret viewport positioned (fixed, sticky) elements wrt virtual keyboard (#7475)

The CSS Working Group just discussed `viewport positioning vs virtual keyboard`.

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> Topic: viewport positioning vs virtual keyboard<br>
&lt;fantasai> github: https://github.com/w3c/csswg-drafts/issues/7475<br>
&lt;fantasai> flackr: [presents the issue]<br>
&lt;fantasai> flackr: Developers want a way to position content that stays in view above a virtual keyboard as it slides into place<br>
&lt;fantasai> flackr: on iOS and ChromeOS this doesn't work today because the virtual keyboard that slides into place changes the visual viewport but not the layout viewport<br>
&lt;fantasai> flackr: You can seen an example here<br>
&lt;fantasai> flackr: the header/footer are clipped and slightly out of view<br>
&lt;fantasai> flackr: behavior on Android today is that we reisze the page<br>
&lt;fantasai> flackr: but this is something that we would like to not do<br>
&lt;fantasai> flackr: just that there has been strong demand for this use case<br>
&lt;fantasai> flackr: there has been a prior suggestion to have a position called device-fixed<br>
&lt;fantasai> flackr: my understanding of how it works is that device-fixed content is outside of pinch-zoom<br>
&lt;fantasai> flackr: and effectively part of the visual viewport<br>
&lt;fantasai> flackr: what we dislike about this is that it's not accessible<br>
&lt;fantasai> flackr: because you can't pinch-zoom this content<br>
&lt;fantasai> flackr: one alternative is scaling the content with pinch-zoom<br>
&lt;fantasai> flackr: but then such content starts massively intruding on the visual viewport<br>
&lt;fantasai> flackr: so what we'd like to propose doing<br>
&lt;iank_> its also quite common for the whole page/app to be within a position:fixed element.<br>
&lt;fantasai> flackr: is defining a viewport that just excludes the virtual keyboard<br>
&lt;fantasai> flackr: but is different from the layout viewport<br>
&lt;fantasai> flackr: so we don't have to do a global reflow when the virtual keyboard shows<br>
&lt;fantasai> flackr: this keeps your headers and footers in position<br>
&lt;fantasai> flackr: you can still zoom around<br>
&lt;fantasai> flackr: this is pretty similar to the effect on android right now with the exception of not changing the actual content layout size<br>
&lt;fantasai> flackr: so we think that it should be Web-compatible for the way that sites exist<br>
&lt;bramus> q+<br>
&lt;fantasai> flackr: unsure about iOS<br>
&lt;fantasai> flackr: I think bramus prefers to move towards iOS behavior<br>
&lt;Rossen_> q+\<br>
&lt;Rossen_> ack \<br>
&lt;Rossen_> q+<br>
&lt;fantasai> bramus: In general, of all these proposals, 5th is what Robert is suggesting<br>
&lt;fantasai> bramus: and I'm in favor<br>
&lt;fantasai> bramus: but I'm not in favor of changing how current position: fixed works<br>
&lt;fantasai> bramus: to counter that, I was thinking of extension to position:fixed<br>
&lt;Rossen_> ack bramus<br>
&lt;fantasai> bramus: where you can specify which viewport you are targetting<br>
&lt;fantasai> bramus: so default is fixed against the layout viewport<br>
&lt;fantasai> bramus: but you would also have options to lay out against the visual viewport<br>
&lt;fantasai> bramus: so that when keyboard is shown ....<br>
&lt;fantasai> bramus: third option is position fixed fixed, positioned against the unzoomed visual viewport<br>
&lt;fantasai> bramus: which is what robert described as option 5<br>
&lt;fantasai> flackr: that's developer optining into either 5 or 4<br>
&lt;fantasai> bramus: the main reason I'm thining along that line is that we wouldn't suddenly change something depending on which platform you're on<br>
&lt;fantasai> bramus: but main advantage to extension to position: fixed syntax is that you can feature-detect<br>
&lt;fantasai> iank_: What's the behavior on Android today?<br>
&lt;fantasai> bramus: what we do right now on Anrdoid is that the layout viewport gets resized when you show a virtual keyboard<br>
&lt;fantasai> bramus: demo on screen<br>
&lt;fantasai> iank_: there's a difference also between position:absolute into ICB vs position:fixed<br>
&lt;fantasai> iank_: what's the difference there again?<br>
&lt;fantasai> flackr: position:fixed lays out against the ??? viewport<br>
&lt;TabAtkins> fantasai: one problem i've often encountered is the heades and footers respond to the position of th ekeyboard, and i'm trying to type into something and i can't see it anymore, bc there's not enough space left<br>
&lt;TabAtkins> fantasai: I'd like for us to not have this problem happen by default<br>
&lt;Rossen_> ack fantasai<br>
&lt;TabAtkins> fantasai: I think visual viewport isn't what we're targeting; again pinch-zoom must not be responded to<br>
&lt;flackr> +1<br>
&lt;TabAtkins> fantasai: what we want is remaiing space after we remove virtual keyboard<br>
&lt;TabAtkins> bramus: rob has been using 'unzoomed virtual viewport'<br>
&lt;TabAtkins> flackr: suggested calling it fixed viewport<br>
&lt;TabAtkins> fantasai: hard not having webkit here, but i recall explaining this as two ways to handle virtual keyboard<br>
&lt;bramus> s/virtual/visual/<br>
&lt;flackr> qq+<br>
&lt;TabAtkins> fantasai: one the keyboard takes up space, another it floats over the content<br>
&lt;TabAtkins> fantasai: i think they follow the floating model<br>
&lt;TabAtkins> fantasai: so the way keyboard interacts is probably affected by that choice<br>
&lt;TabAtkins> fantasai: i think having a special 'fixed viewport' for when you want to attach something to the keyboard or remaining space is reasonable, but i dont' think it shoudl be default<br>
&lt;Rossen_> ack flackr<br>
&lt;Zakim> flackr, you wanted to react to fantasai<br>
&lt;fantasai> flackr: The first behavior I demoed, keyboard floating overtop content, is iOS keyboard<br>
&lt;TabAtkins> flackr: the behavior i demo'd is the behavior iOS has, where effectively the keyboard is floating. it does shrink visual viewport but otherwise doens't affect anything<br>
&lt;fantasai> flackr: option 5 is the same, except you have a viewport that is remaining space<br>
&lt;iank_> q+<br>
&lt;Rossen_> ack Rossen<br>
&lt;fantasai> bramus: and not affected by pinch zoom<br>
&lt;fantasai> Rossen_: Generally speaking, 2 main use cases are iterated have to do with in-page UI that wants to behave more or less close to the way external host UI appears or disappears or behaves<br>
&lt;fantasai> Rossen_: whether this is a keyboard or navbar or search bar<br>
&lt;fantasai> Rossen_: these various permutations are places we want to target<br>
&lt;fantasai> Rossen_: and to push the use cases a little further<br>
&lt;fantasai> Rossen_: as the UI animates in and out, you want to make sure that your stuff animates smoothly with it<br>
&lt;fantasai> Rossen_: this is where device-fixed ideas came in the past<br>
&lt;fantasai> Rossen_: we had a prefixed implementation of this back in the Edge platform where we used position:fixed for UI in PWAs and web apps<br>
&lt;fantasai> Rossen_: in windows<br>
&lt;fantasai> Rossen_: That worked pretty well, but it had the flaw pointed out that they don't zoom in and out with the page<br>
&lt;fantasai> Rossen_: which is exactly what you want, because you're trying to behave closer to the way this native UI behaves<br>
&lt;fantasai> Rossen_: pushing things slightly further, we proposed at some point as part of a larger proposal<br>
&lt;fantasai> Rossen_: a different way of dealing with this which was to expose an environment variable for where the folds are, the top or the bottom folds of the device<br>
&lt;bramus> s/and not affected by pinch zoom/and its sizing not affected by pinch zoom/<br>
&lt;fantasai> Rossen_: I recall a discussion in IIRC Coruña that was extending this further<br>
&lt;fantasai> Rossen_: maybe it was presented by jensimmons at the tme<br>
&lt;Rossen_> https://github.com/w3c/csswg-drafts/issues/4736<br>
&lt;fantasai> Rossen_: that proposal to me was the one that was solving a lot of what was being described here<br>
&lt;fantasai> Rossen_: my question is, there has bene a lot of work and thinking happening here over past 3-4 years<br>
&lt;fantasai> Rossen_: and yet, i'm surprised we're going back to trying to reinvent this<br>
&lt;fantasai> Rossen_: rather than collecting all of the thinking and getting a path forward<br>
&lt;fantasai> Rossen_: Rob or Bramus, was this approach considered or considered and not deemed appropriate or...? what happened?<br>
&lt;Rossen_> q?<br>
&lt;fantasai> flackr: In WICG there's an overlays flag<br>
&lt;fantasai> flackr: you get an environment variable for the size of the keyboard<br>
&lt;fantasai> flackr: the developer is picking up the complexity of where the keyboard should be<br>
&lt;fantasai> flackr: up to them to do the right thing in response to keyboard showing<br>
&lt;fantasai> Rossen_: that seems another permutation of what we're discussing<br>
&lt;fantasai> flackr: that is something shipping in Chrome but not any other browser<br>
&lt;fantasai> flackr: but has complexities because, e.g. you can't scroll to the bottom of the page<br>
&lt;fantasai> flackr: because the keyboard is not considered in your page layout at all<br>
&lt;fantasai> flackr: unless you look to see, how much of the page is my keyboard obscuring<br>
&lt;fantasai> bramus: it also doesn't resize the visual viewport<br>
&lt;fantasai> flackr: that's a bug<br>
&lt;fantasai> Rossen_: I think we should also consider the other discussion of some of the environment variable sand how they play<br>
&lt;fantasai> Rossen_: desire to account for scrollbar etc.<br>
&lt;fantasai> flackr: I have considered some of this, and the initial thinking was that it is complex to do the right thing<br>
&lt;fantasai> flackr: to take all of this into account as a developer<br>
&lt;fantasai> flackr: we wanted to have an easy thing for devs to use, to handle most of the use cases<br>
&lt;fantasai> Rossen_: every time we want to expose a new unit, that's a last step<br>
&lt;fantasai> fantasai: we already rejected that<br>
&lt;fantasai> fantasai: that's not the discussion here<br>
&lt;fantasai> flackr: what's being proposed here is either new positioning scheme or re-intepreting 'position: sticky'<br>
&lt;fantasai> fantasai: sticky?<br>
&lt;fantasai> flackr: we would need to also address sticky, ensure those are still in view<br>
&lt;fantasai> fantasai: I understand wanting that to work... but also... I see so many pages that assume there'll be enough space left and there isn't space to see what I'm typing into<br>
&lt;fantasai> Rossen_: This is why my preference is for this environmental awareness is better expressed in environment variables which you can add to your calc() expressions<br>
&lt;fantasai> Rossen_: and then can improve UI clutter depending on how much space you have left<br>
&lt;fantasai> Rossen_: with positoin, you have to work backwards to see how large it lays out, and then if you don't like it go back and remove it<br>
&lt;fantasai> Rossen_: much heavier option<br>
&lt;flackr> Something like position: fixed; bottom: env(keyboard-height); ?<br>
&lt;fantasai> Rossen_: would much rather do a conditional on a calc() expression and do everything pre-layout<br>
&lt;fantasai> Rossen_: would prefer to do that pre-layout to decide if element continues to be there or not<br>
&lt;fantasai> Rossen_: for example, but can do more than that?<br>
&lt;fantasai> fantasai: Curious what Rossen means by "do more"<br>
&lt;fantasai> fantasai: but also, wrt that example, we would want insets from each edge of the screen, similar to the safe-area insets<br>
&lt;fantasai> Rossen_: what you just described. Need all 4 sides<br>
&lt;emilio> q+<br>
&lt;fantasai> flackr: One complication with that<br>
&lt;fantasai> flackr: right now adding keyboard inset to the bottom work, but I pan down it's at layout viewport plus keyboard height<br>
&lt;fantasai> bramus: if something is position: fixed; bottom: keyboard-height, it would obscure ???<br>
&lt;fantasai> bramus: because you aren't taking the offset of the visual viewport measured against the layout viewport into account<br>
&lt;fantasai> Rossen_: ...<br>
&lt;fantasai> iank_: One quick thing, rob, I'm assuming that any proposal<br>
&lt;fantasai> iank_: we're going to be compat-constrained on Android pretty heavily<br>
&lt;Rossen_> s/.../not if we are exposing the insets env values/<br>
&lt;fantasai> iank_: because ppl are relying heavily on our current behavior<br>
&lt;fantasai> flackr: we have a lot of interop differences, e.g. iOS vs Android<br>
&lt;fantasai> iank_: yes, but ppl know this and have written code to make it work on each platform<br>
&lt;fantasai> flackr: I suspect that's true<br>
&lt;bramus> q?<br>
&lt;fantasai> iank_: I just wanted to make one thing clear, we're in a very sucky position here<br>
&lt;fantasai> iank_: but I don't think that Android or Android webview would be able to change behavior here<br>
&lt;fantasai> iank_: same with iOS<br>
&lt;Rossen_> ack iank_<br>
&lt;Rossen_> ack emilio<br>
&lt;fantasai> (basically, we are doomed to non-interop?)<br>
&lt;fantasai> emilio: At a glance, from my phone, ?? behae like Chrome and Firefox<br>
&lt;fantasai> emilio: resizes and fixes stuff<br>
&lt;fantasai> emilio: the problem with iOS behavior is can you even see something at the bottom of the page?<br>
&lt;fantasai> flackr: when you pan, you're moving the visual viewport and can scroll to the bottom of the page<br>
&lt;fantasai> iank_: I think it's still true that there are various tricks ppl do to get it to autoscroll down into that position<br>
&lt;fantasai> flackr: When you focus an input, it scrolls into view, and that moves the visual viewport<br>
&lt;fantasai> iank_: but ppl exploit various tricks on iOS to get the visual viewport to scroll to the end of the layout viewport<br>
&lt;fantasai> bramus: tricks I've seen ppl use is to steer away from the behavior where the browser automatically tires to center the input into the visual viewport<br>
&lt;Rossen_> q?<br>
&lt;Rossen_> another relevant topic to review is https://github.com/w3c/csswg-drafts/issues/1693<br>
&lt;fantasai> flackr: the reason you can get to the bottom is the browser knows the size of the keyboard and shrinks the visual viewport by that amoutn so you can scroll that much extra<br>
&lt;fantasai> emilio: do stuff like ??? on iOS, on the keyboard, presumably their inputs fix to the top fo the keyboard right?<br>
&lt;fantasai> emilio: like Anrdoid is doing right now<br>
&lt;fantasai> emilio: On one hand I get that it's nice to not resize the layout viewport<br>
&lt;fantasai> emilio: but something like either your proposal, which is fine, or current android/chrome proposa, seems more towards what authors want<br>
&lt;bramus> q+<br>
&lt;fantasai> emilio: when is the iOS behavior preferable right now?<br>
&lt;flackr> +1<br>
&lt;fantasai> emilio: when you have iOS app, if it behaves like Android<br>
&lt;fantasai> Rossen_: you have to do all kinds of funky UA detection stuff<br>
&lt;fantasai> flackr: native apps behave like ???<br>
&lt;fantasai> emilio: they behave like Chrome/Firefox<br>
&lt;fantasai> flackr: option 5 was designed to be more like native app behavior<br>
&lt;fantasai> bramus: what I like about proposal is that it allows authors to have both behaviors<br>
&lt;fantasai> bramus: so if author wants bottom bar not affected by showing keyboard, can get that<br>
&lt;Rossen_> ack bramus<br>
&lt;fantasai> bramus: should they want android behavior, authors can also retain the existing behavior by doing feature detection<br>
&lt;iank_> does the proposal allow Android &amp; iOS to keep the current default behaviour?<br>
&lt;fantasai> bramus: but would require landing both changes on Android at the same time<br>
&lt;flackr> qq+<br>
&lt;fantasai> bramus: so authors can choose to have something at the bottom bottom, or above the on-screen keyboard<br>
&lt;fantasai> iank_: does someone have an existing PWA, we're not changing default behavior?<br>
&lt;fantasai> bramus: Twitter app<br>
&lt;fantasai> flackr: what are you proposing the default is?<br>
&lt;fantasai> bramus: default would be to have position:fixed as before, lay out items against the outer viewport<br>
&lt;fantasai> bramus: that would be the iOS behavior<br>
&lt;fantasai> iank_: we can't do that<br>
&lt;Rossen_> q?<br>
&lt;Rossen_> ack flackr<br>
&lt;Zakim> flackr, you wanted to react to bramus<br>
&lt;fantasai> flackr: bramus brought about customizing behavior<br>
&lt;fantasai> flackr: the virtual keyboard overlays content behavior allows complete customization of the bheavior<br>
&lt;fantasai> flackr: if you're a site that wants to customize ythe behavior, you can do that<br>
&lt;fantasai> flackr: this is more about having sensible defaults that work well<br>
&lt;fantasai> Rossen_: So, let's figure out some next steps<br>
&lt;fantasai> Rossen_: most of the conversation seems to be circling around the option 5 that you proposed<br>
&lt;fantasai> Rossen_: we cna record that this is the current preferred method<br>
&lt;Rossen_> ack fantasai<br>
&lt;TabAtkins> fantasai: bramus was suggesting there be various syntactic ways of opting into different behaviors<br>
&lt;TabAtkins> fantasai: i think this is something that, if we want to add it, it shoudl be an independently cascade property from position<br>
&lt;TabAtkins> fantasai: likely you'll think abuot how your stuff adapts at a different level from how it's laid out<br>
&lt;TabAtkins> fantasai: so it should be a different prop<br>
&lt;TabAtkins> fantasai: position:fixed, and a "fixed-to:whatever" prop<br>
&lt;fantasai> s/different/independently cascading/<br>
&lt;fantasai> Rossen_: do we need to take any resolution on these proposals?<br>
&lt;fantasai> flackr: We would like to get more feedback<br>
&lt;fantasai> Rossen_: seems we've clearly indicated favorable options, should be easier to page in next time<br>
&lt;fantasai> I also wonder if we want to do this *and* have the environment variables<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7475#issuecomment-1204324591 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 3 August 2022 18:25:25 UTC