Search input gets hidden under keyboard until user starts typing #58
Labels
No labels
Agent/Chrome-Android
Agent/Chrome-Desktop
Agent/Chrome-iOS
Agent/Firefox-Android
Agent/Firefox-Desktop
Agent/Firefox-iOS
Agent/Safari-Desktop
Agent/Safari-iOS
Code/Backend
Code/DevOps
Code/Frontend
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority/Critical
Priority/High
Priority/Low
Priority/Medium
Reviewed/Confirmed
Reviewed/Duplicate
Reviewed/Invalid
Reviewed/Won't Fix
Status/Abandoned
Status/Blocked
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
aniram/cidadon#58
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Suggestion: Quick investigation. 1h max. If a solution is not found add an item to the UI refactoring issue to put the search input at the top to get rid of future problems, this has already cost me a lot of time.
The problem:
While the user scrolls the browser's navigation bar, where the URL is, disappears to increase the screen's visible area.
This behavior causes the input field to get stuck under the keyboard when the user clicks inside the search input after it was expanded. Only when the user starts typing does the input become visible again. This only occurs when the user tries to type while they are scrolling. If the page isn't moving then the navigation bar is present, and this does not happen.
Firefox on Android does not make the navigation bar disappear so this does not happen.
The navigation bar being on the bottom is not the default setting.
Search input gets hidden under keyboard until the user starts typingto Search input gets hidden under keyboard until user starts typingOn some websites like https://devdocs.io/javascript the browser's navigation bar does not disappear on scrolling.
https://developer.mozilla.org/en-US/docs/Web/API/VirtualKeyboard_API#browser_compatibility
Using the VirtualKeyboard API could solve this problem but at the same time it would potentially create many others as this is a low-level API that instead of letting the browser push the viewport up to show the keyboard, it lays the keyboard over it, making it 100% our responsibility to modify the viewport on keyboard open and close events. Currently I have a small POC working on branch feat/use-virtual-keyboard-api but it has a bug on Chrome as this API is currently only available there.
The bug is as follows:
I'm on the homepage, no results are shown.
I click on the address bar and then on the URL. The keyboard shows up.
It does not appear on the page where I was but instead on a browser specific page.
This is normal behavior. So far so good.
If while I'm on this page I click on the URL under the address bar which happens to be the URL of the page I was in then the browser will trigger a page refresh.
Here comes the bug.
The new page will now have as its height the viewport height plus the keyboard height although the keyboard is not visible anymore as it got dismissed when the page refreshed. Since I'm using the Virtual Keyboard API the keyboard is overlaying the content which now means it's hiding the search button as the screenshot shows.
Clicking on the page, brings focus to the document and makes the search button appear as well as the viewport height to back to its normal value.
On the screenshots we can see a picture where the height is 1932px and the search button is hidden, and another one where the height is 1381px with a visible button.
Proposed solution:
I've investigated how OpenAI™ ChatGPT hides and shows the text area where users enter their prompt to the LLM.
They use the VirtualKeyboard API in a more selective way. Instead of listening to the geometrychange event, that is fired whenever the keyboard enters/leave, to change the viewport's height they first listen to the focusin event and only then do they opt-in on the VirtualKeyboard API and add the event listeners for geometrychange. This ensures that the page will adapt its layout to keyboard related events only when the page receives user focus. Without it, by opting in to the VIrtualKeyboard API per default, we have to deal with all kinds of possible edge-cases we don't want to, so we should only opt-in in when our usage case actually happened. After the keyboard was dismissed, they clean-up by opting out again.
The code below belongs to OpenAI™ and is shown here only as a case-study.
On the very bottom I've added some commentary of my own.
1a7ebd5f-n8t4mic0ryk6vjax.js
Try using this instead of manually toggling CSS classes.