-
Notifications
You must be signed in to change notification settings - Fork 96
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
Implement global lazy loadable support for tabs #1309
Conversation
This change adds support for a new global .lazy-loadable selector. Nodes with this class will receive a "lazyload" event to allow them to display content upon tab activation. This also fix lazy-loading not being applied properly inside cms-tabset (they don't have the ss-tabset class).
selector should include cms-tabset, since they don't have the ss-tabset class by default
Co-authored-by: Michal Kleiner <mk@011.nz>
@michalkleiner sorry my bad, this is what happens when you simply edit stuff through github ;-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in general - the approach is nice and general, and it's resolving some problems with lazy-loadable gridfields that probably have been unnoticed (or just ignored) for a while.
The new .lazy-loadable
class and the native event should be added to the relevant documentation and there are a few other fairly small changes here to make.
Please also run |
@GuySartorelli hey, sorry, this is probably the worst pull request ever. I did work from the uncompiled source because I have issues running yarn build locally. I'm reviewing things with a fresh mind to make sure it's more like a proper PR :-) |
@GuySartorelli so I gave this another shot. There is a confusing part for me. There are currently two different entwine bindings, one for .ss-tabset, and one for both .ss-tabset and .cms-tabset. But as far as I can tell, this serves no purpose, since lazy loading should apply to both and the redraw tabs feature is guarded by a class check. I've just refactored the whole thing to merge them together... it should be working well this way I didn't manage to run yarn build, i get this error |
^10.x is weird, but essentially means any minor on 10.x. |
@michalkleiner ah makes sense supporting newer major versions might be a hassle, but staying on older versions might be just as bad... i mean, if there is a full guide somewhere on how to use the build tools, I'm all for it, but installing node 10 and running yarn build doesn't work (at least on windows with the way i've installed things) |
@lekoala after switching to node 10, did you |
@kinglozzer thanks for your help on this nvm use gives me "invalid version" as a result (maybe windows specific?). still, i get pick my version and use a valid branch removing node_modules was a good idea, but it doesn't solve the issue i get this
so it seems it's either eslint or sass-lint that doesn't get installed. I've tried with node v12, it doesn't work due to engine restriction. I really think upgrading to at least node 12 would make sense as eslint doesn't seem to support at all node v10. |
Node 10 works fine for me, eslint and all. I don't undertand why nvm heckles you about the version... did you
This is something we're aware it pretty lacking at the moment. But improving documentation is a lengthy process and nobody has made time to do it yet.
I agree in general - but this isn't something we're going to look at doing in the immediate short term. |
@lekoala I've built the js and pushed it to your PR branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally got around to taking a look at this post-refactor. It looks like some of the functionality (onremove
, redrawTabs
, rewriteHashLinks
, etc) may have been intentionally omitted from .cms-tabset
.
<%-- Exclude ".ss-tabset" class to avoid inheriting behaviour --%> |
Can you please undo the refactoring? The only change to .cms-tabset
should be that it now includes lazy loading.
Co-authored-by: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com>
Co-authored-by: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com>
Co-authored-by: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com>
@GuySartorelli ok so I made this dead simple, i simply add my new function to cms-tabset and ss-tabset (so that it works everywhere and doesn't break anything). it really depends i guess if you think it's worthwhile to support this as a core feature or not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry it's taken me so long to look at this again.
I still think it makes sense for lazyLoadGridFields
to be moved into the $('.ss-tabset, .cms-tabset')
entwine set - I had intended this when I said "The only change to .cms-tabset should be that it now includes lazy loading" but I should have been more explicit about it.
I'm certain that was intended, since .cms-tabset
is checked inside that function and the docs say that's the class that should explicitly work with lazy loading.
If you can make that change along with the other small changes I've requested, I'll build the bundle for you again, test locally, and we can let CI do its thing - if that passes then I'll be happy with it.
We need docs for this as well as I've mentioned before, but that will be in the framework repository anyway so I'm okay so it has to be a separate PR, so I'm okay with merging this PR without docs for now - it would be super cool if you can create a new PR in framework to add docs, but I'm happy to do it if you don't.
@GuySartorelli when I started working on the PR, I thought it would be useful as a global feature (because it would be logical to offer this feature for other types of fields if a generic way) and i didn't imagine it would be difficult to run the build pipe ;-) now actually i realize that maybe its also overcomplicating things. :-) but if you find the PR interesting, maybe it's easier that you proceed and modify things yourself, you already did much of it anyway and it will be easier to run the build pipe and make sure styling is consistent with your requirements. What do you think? |
I agree, it sounds like something that would be useful to have in core for sure.
Like I said, happy to take care of that part for you.
I don't think it's overcomplicated at all. Technically just about anything can be added to a project with some extra code. ;P I think this change makes sense in core though.
There hasn't been any real attempt to convert entwine functionality to react for quite a while, and I don't see it being in the works any time soon either.
I think it's pretty close to done, there's just the suggested changes I've mentioned above. If you'd rather not do them that's fine, though - I understand this all takes time so no pressure either way. If you want to close the PR, I might pick it up at some point, otherwise if you want to make those changes then as I've said if it passes testing I'll be happy to merge it. |
Co-authored-by: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com>
Co-authored-by: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com>
Co-authored-by: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com>
Co-authored-by: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com>
Co-authored-by: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com>
Co-authored-by: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com>
@GuySartorelli mhh don't mind me, i'm sometimes a bit disappointed by how much time it takes to follow up a PR that would probably take no more than 10 minutes for a solo dev :-) I'd be happy to make a PR to the docs once it's merged |
Looks good, works well locally. Thank you for this, it's a great idea. |
@GuySartorelli here are the docs ;-) PR reference : silverstripe/silverstripe-admin#1309
For context, see issue
#1308