Page MenuHomePhabricator

Use Back key on Android to close Wikipedia Preview
Open, MediumPublic

Description

Problem

Allow Wikipedia Preview to be dismissed using the back key on Android devices.

Solution

Currently, Wikipedia preview can be dismissed either by tapping on a close icon or the area outside the preview. On Android devices along with these two interactions, we can also use the back(soft/hard) key to dismiss the preview.

This is how back key would work.

  • If a preview is active is normal(before tapping on continue reading) or expanded mode(after tapping on continue reading) then back key will close the entire preview.
  • If an image is active in full-screen mode from preview then back key closes the image and control goes back on the preview.

Note: This change is only for android devices, on iOS devices users will be using close icon or area outside to dismiss the preview.

Event Timeline

AMuigai renamed this task from Use Back key to close Wikipedia preview to Use Back key on Android to close Wikipedia Preview.Aug 4 2020, 5:01 PM
AMuigai edited projects, added Inuka-Team (Kanban); removed Inuka-Team.
AMuigai triaged this task as Medium priority.Aug 4 2020, 5:10 PM

Technical details :

in Android web page

(1) Overwrite the back key function when preview/gallery is opened, once closed, the original function is reverted;

ANS: Whenever the back key is pressed, the browser brings you to previous page, and there is no way for client side to hijack and stop the default behaviour

OR

(2) Control the history state; source code reference;

ANS: Refresh the page when the preview/gallery popup is opened, and the history state remain if we don't clean it
OR

(3) does adding the parameters to the address URL works?

ANS: Idea similar to (2)

Could someone found some live example for this? what I notice most of the site it modify the URL path [1], so when the user refreshes the page, the popup content remains until press close or back key.

[1] one example for linkedin profile page, click profile pic or any edit section for the popup as well as update the URL path.

Any solution that uses the URL or the history API has a high potential of conflicting with routing on the host website. Maybe a pushState with everything identical except for some metadata could work but we would need a switch to turn it off since it's almost impossible to test all possible setup a partner could have in terms of routing.

A key event for the back key would really be ideal. If not possible I'm not sure we should go ahead with this task.

Any solution that uses the URL or the history API has a high potential of conflicting with routing on the host website. Maybe a pushState with everything identical except for some metadata could work

I'm thinking so, if the user refresh the page, history remains but we don't show popup, if user press the back key here nothing change, unless press back key twice. In such case, we may trigger history.back() when window load but it's not a good solution as the host website may update the history during the page load.

but we would need a switch to turn it off since it's almost impossible to test all possible setup a partner could have in terms of routing.

Yes, recommend to have it.

A key event for the back key would really be ideal. If not possible I'm not sure we should go ahead with this task.

if we don't modify the history, back key will bring user back to the previous page, not the page before popup open.


@SGautam_WMF and I will find more examples here

Another example was given here in Google Image Search Result, it uses the history state + hash, press back/forward key to see result, as well as refresh.

image.png (975×1 px, 1 MB)

After several searching [1] Linkedin Profile Page, [2] Google Image Search Result [3] Mobile Wikipedia Web Page, these 3 use the similar technic to update history state + hash, press back/forward key and refresh will get the result whenever user in before;

Wikipedia Preview stands as a 3rd party library, it shouldn't affect how the host routering the page unless we have confirmed with the host partner.

If we do this, I also agree that this feature disable by default and allow to turn on when needed; in addition, I suggest this can be the scope for all platform browser, not android browser-specific only.

SBisson edited projects, added Inuka-Team; removed Inuka-Team (Kanban).
SBisson added a subscriber: hueitan.

Pushing back to the backlog until this comes up from partners or readers. The challenge here is to do something generic that doesn't interfere with the routing on the host website.