cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cedric Reichenbach (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CB-13947) Back button behavior doesn't revert to default when removing listeners
Date Mon, 05 Mar 2018 21:00:00 GMT

     [ https://issues.apache.org/jira/browse/CB-13947?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Cedric Reichenbach updated CB-13947:
------------------------------------
    Description: 
When adding a {{backbutton}} event listener to {{document}}, Cordova disables default back
button behavior (which is usually closing the app).

Later, when removing the last event listener, it should re-enable default behavior, but does
not.
h2. Technical details

Internally, cordova seems to use a channel to handle document event listener registrations,
which should update the override state on every listener addition/removal: [https://github.com/apache/cordova-android/blob/eddad666ff60129bf716cee61c24d3d65741640f/bin/templates/project/assets/www/cordova.js#L1664]

However, debugging indicates that {{onHasSubscribersChange}} is only triggered once, when
adding a listener for the first time, but never on removal.
h2. Workaround

As described [here|https://stackoverflow.com/a/49087662/1090166], one can manually update
the override state, e.g. to disable:

{code:javascript}
navigator.app.overrideBackbutton(false);
{code}

  was:
When adding a `backbutton` event listener to `document`, Cordova disables default back button
behavior (which is usually closing the app).

Later, when removing the last event listener, it should re-enable default behavior, but does
not.
h2. Technical details

Internally, cordova seems to use a channel to handle document event listener registrations,
which should update the override state on every listener addition/removal: [https://github.com/apache/cordova-android/blob/eddad666ff60129bf716cee61c24d3d65741640f/bin/templates/project/assets/www/cordova.js#L1664]

However, debugging indicates that `onHasSubscribersChange` is only triggered once, when adding
a listener for the first time, but never on removal.


> Back button behavior doesn't revert to default when removing listeners
> ----------------------------------------------------------------------
>
>                 Key: CB-13947
>                 URL: https://issues.apache.org/jira/browse/CB-13947
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-android, cordova-js
>    Affects Versions: cordova-android-7.0.0
>            Reporter: Cedric Reichenbach
>            Assignee: Joe Bowser
>            Priority: Major
>
> When adding a {{backbutton}} event listener to {{document}}, Cordova disables default
back button behavior (which is usually closing the app).
> Later, when removing the last event listener, it should re-enable default behavior, but
does not.
> h2. Technical details
> Internally, cordova seems to use a channel to handle document event listener registrations,
which should update the override state on every listener addition/removal: [https://github.com/apache/cordova-android/blob/eddad666ff60129bf716cee61c24d3d65741640f/bin/templates/project/assets/www/cordova.js#L1664]
> However, debugging indicates that {{onHasSubscribersChange}} is only triggered once,
when adding a listener for the first time, but never on removal.
> h2. Workaround
> As described [here|https://stackoverflow.com/a/49087662/1090166], one can manually update
the override state, e.g. to disable:
> {code:javascript}
> navigator.app.overrideBackbutton(false);
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message