-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Reopen the last article after switching between menu items #127
Comments
Kiwix-js-windows now implements re-displaying the last article after switching back from "Config", without re-loading the article. (It also disables the link back to the article if the user has switched CSS display mode, as this necessitates reloading the article). I'm in the process of backporting to kiwix-js to commit just the switching between tabs to a new branch built on the main branch (so as to be able to make a PR for testing from main). The testing branch is here: https://github.com/kiwix/kiwix-js/tree/Return-to-last-article-from-config-without-reloading , but it has no changes yet. If anyone wants to test the full feature set, they need to do so on kiwix-js-windows until I edit this message. Edit: backport is now complete - see PR #291 . |
This implements the most urgent aspects of #127 (Reopend the last article after closing/reopening, or after switching between menu items). It implements a link to go back to the article, and disables the link if a major UI option is changed (so as to force a reload). It does not implement storing the article title in a cookie.
As discussed in #291, I think switching between menus should "naturally" keep the context. A second step would be to store what's necessary in a cookie, so that to be able to re-open the same article after closing/re-opening the app. Which is a bit more complicated because of the different ways to open a ZIM file |
I renamed this issue, to narrow it to what can be implemented for now : be able to return to the same article after going to another section (settings, or about) |
OK. It is possible to remember the last page for each ZIM and load it after the user has picked the ZIM. We simply store a cookie value like |
You're right
That's why I think it's better to keep it in kiwix-js-windows, without backporting it for kiwix-js (where it would only be useful for the dead Firefox OS...). With this renamed issue, it should be not necessary to store the info in a cookie, and there will be no privacy concern |
@D3V-D Issue is partially fixed in that the code to go back to the article view and unhide any article that is currently loaded is in the codebase, but what hasn't been successfully implemented to date is the "unclicking" action on the menu buttons, so you could click on Config, then unclick it and the loaded article would show. |
@Jaifroid Yeah I realized this a bit belatedly. In the meanwhile, I might be interested in working on this issue, but I'll take a closer look at it first. |
Okay, so for unclicking, is that whenever I click on the config section the second time? Or is it when I'm on the config section and I click anywhere on the section that isn't a button and it un-highlights the config tab? I'm a bit unsure as to when or why we would want to go back to the article by "unclicking" |
@D3V-D Effectively the "Config" button should remain selected while Config is showing, and then when you click again on it, the button is visually deselected and we return to whatever article is loaded. When a user clicks on "Home", conversely, the landing page will be loaded again. Same with the "About" button (should act same as Config). You can see, roughly, how this should work by looking at https://pwa.kiwix.org, where that version (with a somewhat different UI) works in this way. To see it properly in action, you need to load a ZIM. |
@Jaifroid Okay, thanks for the PWA link, I see what you mean now! Clicking on the tab the second time should take you back to the article, and clicking the home tab should reload it. I remember a while back I did the drag-over feature, where when dragging it would open config, but once you drag-exit it went back to the ZIM, I think without fully reloading it (I can check again), maybe that would work just fine here as well? And reloading the ZIM should be easy enough when clicking home |
Actually I think the PWA may reload the ZIM when unclicking, but I think the Kiwix-JS extension doesn't when drag-exiting. EDIT: Nevermind, after some testing I don't think either reload the ZIM entirely. |
The infrastructure is all there, it's just about hooking the relevant functions into the Config and About buttons, so they unhide the main article when clicked if they are currently selected. And then there's the cosmetic issue of ensuring the buttons look like they are clicked and unclicked. I don't think the PWA actually reloads the ZIM when clicking on Home, it just calls the |
@D3V-D It's |
@Jaifroid Okay, thanks for the info! Hopefully it's as easy as it sounds, but I'll probably work on it sometime next week |
@Jaifroid Is there some variable that tracks which page we're on (Config, About, or Home)? |
While loading an article, you can get Note that when I did something similar for the PWA, I had to beware of two issues:
|
@Jaifroid oh that's also good to know, but I meant moreso tracking whether we're currently on config, about, or home tab in the top bar Edit: Wait,let me actually try something else first |
OK, sorry I misunderstood. You can use the methods in https://github.com/kiwix/kiwix-js/blob/main/www/js/lib/uiUtil.js#L760 to determine which section is currently visible. So, basically, just call |
@Jaifroid Where can I access the bootstrap styles? E.g the styles for the :focus on the buttons in the top bar. I don't see them in any of the CSS files in the CSS folder. |
Bootsrap is loaded here: https://github.com/kiwix/kiwix-js/blob/main/www/index.html#L42 As you can see, it's loaded from the node_modules folder that will only be present on your system if you have done When the bundler (rollup) is run, this file is moved into the app, so it's all self-contained after bundling. However, that's all a bit moot, because you shouldn't of course modify the source code for bootstrap (this can change whenever a new version is added). You should instead write override styles, if you need to, in |
@Jaifroid Ahh, okay. I was wondering since I'd like to remove the focus styles on the buttons and instead apply those styles whenever the page is active. So, how would you say I do this? I assume there's some way I can remove those styles? (I don't really work with bootstrap often sorry) |
Hmm. I think :focus is an inbuilt attribute that is added whenever an element has focus, and that's done by the browser. I'm not 100% sure of this, but it rings a bell. This means you can't remove it. But you can override it in |
Yes, you're correct on focus being applied by the browser, but I'm moreso asking if I can somehow just prevent the :focus styles themselves from being implemented at all? :focus can be present without the styling. Of course, I can just override the styles if need be but I figured it'd probably be better to remove than to override Edit: I've looked at the link you've provided, that's helpful; I'll probably use the active class myself. |
If they're bootstrap-defined styles in bootsrap.min.css, then you can't edit them out. And you've already searched in app.css, so they're not defined there. I think the only solution if you don't like the focus style is to override them. But it's possible that when you write a style for the |
Got it, time to just test it out on my end, thanks for all the help though I appreciate it Note: The .active class actually applies to the .li item instead of the actual button, so I may have to make my own class here, but same concept I believe |
@Jaifroid I've got a working fix, just need to run tests. It's fine in Before I test the other parts I'd like to make sure the preview is working correctly (though the unit tests and e2e tests seem to be passing from what I see, as well as serviceWorker and restricted modes) |
Ah, OK! You might be able to avoid adding another class by using a style rule such as |
Make sure |
Oh, smart. Might have to do that... for now I've got it done with just a new class though, up to you if I should avoid creating a class or not; would probably cut out a lot of JS. |
No problem! Yeah I had it on, not sure why it doesn't show. I'll try a few more tests soon then I'll just send a PR over with the unbundled version. |
No problem, whatever you think is best -- if I see a simpler way in the PR, I can always suggest it. |
@Jaifroid Not sure if you've already seen it but I've gone ahead and made the PR last night. Let me know if anything looks off |
A cookie might keep the last article
The text was updated successfully, but these errors were encountered: