Coder Social home page Coder Social logo

Comments (10)

reenko avatar reenko commented on June 8, 2024

@ademenev It's not a bug.
You can see in code catberry-homepage/catberry_components/pages/index.js:26, we have window.scrollTo(0, 0);} in unbind

from catberry.

ademenev avatar ademenev commented on June 8, 2024

And what about catberry init example? Navigate to commits, then to search, press back, scroll down a bit, press forward, press back - the commits list is at top again, not where it scrolled to

from catberry.

ademenev avatar ademenev commented on June 8, 2024

https://judo-heroes.herokuapp.com - that's an example of how I think the things should work in regard of scrolling and browser's back/forward buttons

from catberry.

rdner avatar rdner commented on June 8, 2024

That is not what website visitor would expect

What would happen if it was a regular server rendered app? I believe it would be exactly like Catberry behaves, right?

In fact, the whole page state is lost. If there would be a text input on Main page, and I enter some text there, then navigate to Overview, and then press back - that input will be cleared (this can be observed on flamp.ru, for example)

Same here, if you want to store it somewhere you need to implement this behavior in your components using a LocalStorage, for example.

In this particular example, that is an expected behavior because it would work exactly the same in case of a classic server rendered website which people are used to seeing.

This will not change, so if you need another implementation there are many other frameworks/libraries you might like more.

Regarding the state in general, Catberry is an isomorphic framework, all the apps written using Catberry should store any state in URL and decode that state using routes and stores. The only exception off this rule might be an input state while typing, it's suggested to use the LocalStorage for that. Once you submit a form, change the URL to have the state (e.g. using the query string in URL), like the commits search example you mentioned does.

from catberry.

ademenev avatar ademenev commented on June 8, 2024

What would happen if it was a regular server rendered app? I believe it would be exactly like Catberry behaves, right?

It would depend on caching-related headers sent by the server. Generally, browser would not reload the page, and display exactly same content, including any values in form inputs

from catberry.

rdner avatar rdner commented on June 8, 2024

But if you don't scroll to top you can end up with the footer in your viewport which is very confusing for users. In fact, it was an issue from developers reported as a bug to fix this behavior, therefore this code was introduced.

The behavior you're describing is how browsers treat web-sites and it's not under control of an app. When you have a single page application and "change pages" you can't tell a browser to treat it as "back" in history, you actually re-render the whole DOM. So, the only option we have here is to pretend it's a page refresh without caching.

from catberry.

ademenev avatar ademenev commented on June 8, 2024

from catberry.

rdner avatar rdner commented on June 8, 2024

As I've already mentioned:

This will not change, so if you need another implementation there are many other frameworks/libraries you might like more.

from catberry.

ademenev avatar ademenev commented on June 8, 2024

That should be the whole point of the discussion. Not how things shoud behave, but how things framework developers think it shoud behave. Just because implementing the other way is beyond of their vision

I do like catberry, and going to use it in future projects )

from catberry.

reenko avatar reenko commented on June 8, 2024

In Flamp, we save the position in LocalStorage and when the user navigate from feed to review and "back", then we scroll to value from LocalStorage.

from catberry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.