Skip to content
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

back button when popup is open #150

Closed
boynet opened this issue Aug 3, 2014 · 21 comments
Closed

back button when popup is open #150

boynet opened this issue Aug 3, 2014 · 21 comments

Comments

@boynet
Copy link
Contributor

boynet commented Aug 3, 2014

when pushState: true.

1.when popup is open and you press back button(on browser or android not the framework back button) the popup stays and the pages under the popup change.
is there a way to push a state on popup open? so the back button will close the popup?

@nolimits4web
Copy link
Member

No, it is highly depends on layout, and pushState works only for main View. You can just add custom event listener to popstate event:

$(window).on('popstate', function(){
  myApp.closeModal('.popup.modal-in');
});

@boynet
Copy link
Contributor Author

boynet commented Aug 3, 2014

so its not useable except ios :/ there must be a way.
the only problem with pushstate on popup is the refresh will not work?
what do you think of something like:
#!/index.html
with popup:
#!/index.html/popup
on refresh check if its end with /popup if yes remove it

@boynet
Copy link
Contributor Author

boynet commented Aug 3, 2014

I 'hacked' it like so(i dont need refresh it run only as application):
on popup:
window.history.pushState('', '','#!/'+window.history.state.url+'?&popup');
on close popup:
window.history.back();

I still think its need to be solved in the f7 level

@boynet
Copy link
Contributor Author

boynet commented Aug 16, 2014

hi Vladimir
I got few ideas to solve this:
1.add app option something like: pushStatePopup
2. make popup automatic push state
3. add some ready to use code to the popup docs how to solve it
what do you think?

the popup state should be soft something like:
index.html -> click on popup -> index.html?popup
this way after refresh the index.html will load normally

I use it like so:
on popup open:

window.history.pushState('', '', '#!/' + window.history.state.url + '?&popup');

somewhere in the code:

    $$(window).on('popstate', function (e) {
        myApp.closeModal('.popup.modal-in');
    });
    $$(window).on('click', '.close-popup', function () {
        window.history.back();
    });

@ZanderBrown
Copy link
Contributor

Is this resolved?

@valnub
Copy link
Collaborator

valnub commented Jan 22, 2017

Closed due to no reaction by issue author after several months

@valnub valnub closed this as completed Jan 22, 2017
@boynet
Copy link
Contributor Author

boynet commented Jan 22, 2017

@valnub its not solved but I think that nolimits4web not seeing this as bug

@valnub valnub reopened this Jan 22, 2017
@valnub
Copy link
Collaborator

valnub commented Jan 22, 2017

Well, on iOS this definitely is not a bug because there is no such behavior for pop-up (as there is no physical back button on the device).

On Android, yeah one could argue that this needs more refinement.

Maybe someone can create a plugin or pull-request to fix this.

@tinyCoder32
Copy link

Will this be taken in mind soon?
I'm having the same issue on my app, it is made for iOS and Android and having a lot of popups that need to be closed using the Android device back button.

@tinyCoder32
Copy link

I managed to do it as members suggested:

$$(window).on('popstate', function(){
  myApp.closeModal('.popup.modal-in');
});

window.history.pushState('', '','#!/#signup');

We hope that this will be taken into consideration to have an easy option in next versions.

@brainformatik
Copy link
Contributor

@nolimits4web
Please fix that. Everyone (android users) needs that.

@brainformatik
Copy link
Contributor

brainformatik commented Apr 21, 2017

@tinyCoder32 @boynet

Our dirty fix for smart-select popups is this:

$$(document).find('a.smart-select').on('click', function () {
    setTimeout(function () {
            window.history.pushState('', '', '#/' + window.history.state.url + '&popupOpened');

            $$(window).on('popstate', onPopupHistoryBack);
            function onPopupHistoryBack () {
                $$(document).off('click', '.link.close-popup', onPopupCloseButtonClick);
                myApp.closeModal('.popup.modal-in');
                $$(window).off('popstate', onPopupHistoryBack);
            }

            $$(document).find('.popup.modal-in').on('click', '.link.close-popup,.list-block li', onPopupCloseButtonClick);
            function onPopupCloseButtonClick () {
                $$(window).off('popstate', onPopupHistoryBack);
                window.history.back();
                $$(document).off('click', '.link.close-popup', onPopupCloseButtonClick);
            }
        }, 200);
});

But dirty fixes are ugly. It's a framework7 issue, so we hope @nolimits4web has time for it.
The same should be integrated for panels and popovers (with parameters).

@J05HI
Copy link

J05HI commented Apr 21, 2017

@nolimits4web
I need this too for android compatibility, but dirty hacks aren't very good.
I need a real implementation.

@ZanderBrown
Copy link
Contributor

@J05HI With how long these issues have been open i suggest you contribute a 'real implementation'

@J05HI
Copy link

J05HI commented Apr 21, 2017

@ZanderBrown
I'm not familiar with the Framework7 source. I think @nolimits4web can do this better and faster.

@tazzkiller
Copy link

For my apps a use a simple workaround with addClass/removeClass on the body element and my back button check if the body has the class or not before execute any action.

@J05HI
Copy link

J05HI commented Apr 28, 2017

@tazzkiller
Can you please post a code example :)

@tazzkiller
Copy link

tazzkiller commented Apr 28, 2017

@J05HI

$$('.your-popup').on('popup:close', function () {
  $$('body').removeClass('popup-open');
});
$$('.your-popup').on('popup:open', function () {
  $$('body').addClass('popup-open');
});

on your "backbutton" event :

if ($$('body').hasClass('popup-open')) {
myApp.closeModal();
} else {
window.history.back();
}


@valnub
Copy link
Collaborator

valnub commented May 31, 2017

I don't think this will get a fix in Framework7 1.x - As the work on v2 has begun, it might be fixed there as it is more a feature-request rather than a bug.

@ZanderBrown ZanderBrown modified the milestones: Framework7 2.0, Issues Backlog Jun 1, 2017
@nolimits4web
Copy link
Member

Issue is closed because of outdated/irrelevant/not actual/needed more information/inactivity.

If this issue is still actual and reproducible for latest version of Framework7, please create new issue and fill the issue template correctly:

  • Clearly describe the issue including steps to reproduce when it is a bug.
  • Make sure you fill in the earliest version that you know has the issue.
  • Provide live link or JSFiddle/Codepen or website with issue

Bug Report Triage automation moved this from Labeled to Resolved Jan 27, 2018
@J05HI
Copy link

J05HI commented Jan 28, 2018

@nolimits4web
Yeah in v2 it should already work :)

@lock lock bot added the outdated label Sep 25, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Sep 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Bug Report Triage
  
Resolved
Development

No branches or pull requests

8 participants