Comments (10)
@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.
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.
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.
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.
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.
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.
from catberry.
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.
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.
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)
- Tests for watchers in "debug mode" are not passing on Mac HOT 1
- Problems with patching attributes HOT 1
- Pluralsight course for CatberryJS? HOT 4
- Possible to use with [email protected]? HOT 2
- Is it possible to use JSX for templating? HOT 2
- Jade package renamed to Pug and now deprecated HOT 3
- Empty location.hash adds when clicked on link with current location address. Firefox only. HOT 1
- Remove `sendBroadcastAction` method from the context
- Drop IE <=10 support and extend new JavaScript features HOT 6
- Use babili once it's ready HOT 1
- Don't overwrite a bundle file if the hash is the same HOT 1
- Drop Node.js < 6.10
- Catberry 9.0 readiness checklist HOT 1
- Remove `develop` branches and forbid `merge commits`
- Render Document method does not have a check for `null`
- Catberry 9 testing checklist HOT 4
- Sharing state obtained from external source between client and server HOT 2
- npm run debug-win Error HOT 1
- How can I make it better? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from catberry.