FriendsOfFlarum / user-directory

The permission based public user directory extension for your Flarum forum.
https://discuss.flarum.org/d/5682
MIT License
22 stars 20 forks source link

Ghost spinner icon appearing on user directory #8

Closed pr0way closed 3 years ago

pr0way commented 7 years ago

Hi! Today, when I looking for my forum users I find one alarming thing.

I do not know if I can throw it into the error section? This is about the element: error

Sometimes it is visible, but not always, although all users are already loaded.

PS. Sorry for my weak english.

luceos commented 7 years ago

I've noticed the same but haven't found the cause yet. Thanks for reporting I'll look into this.

Braintelligence commented 6 years ago

Strange, when I first installed Flarum today I didn't see this. Now after I needed to reinstall everything I have this problem as well.

clarkwinkelmann commented 5 years ago

I have never experience it myself. But I'm sure it's still present, so I can't really close this.

If anyone has an install where it happens systematically I'd be happy to take a look.

clarkwinkelmann commented 5 years ago

Well I shouldn't have written that so fast. I've just found a way to replicate it.

When already on the users page, if I run m.route('/users') in the console to load the same page again, the spinner shows up and doesn't disappear.

I suppose the same behaviour can be observed if there's a link to the users page and you click it twice.

Still not sure what code is responsible for it though.

clarkwinkelmann commented 4 years ago

I'm going through old issues. This one is kind of an old friend.

I have not experienced the issue again with User Directory since last year. Even my way to reproduce the issue does not work on my beta 12 right now. Maybe it's been magically fixed even though we changed nothing here and nothing appears to have changed in core regarding the spinner either.

I have however experienced the issue while developing other extensions.

It seems that in our old version of Mithril, Mithril is quite happy to reuse the DOM element of a Component for another Component. Because the spinner of spin.js is added directly as a child of the LoadingIndicator, it can end up moving to other components rendered in its place later.

To find a perfect workaround we'd need a way to reliably reproduce the issue. Some of the solutions include wrapping the loader in a keyed element, or wrapping it in multiple DIVs so that Mithril will have no choice but delete the parent of the spinner when re-rendering.

What's odd is that in this issue, the spinner appeared on top of the first post, even though it's a child of the load more section which is supposed to be at the bottom.

One reason could have been that because the load more section doesn't have a key, the div is re-used for the first keyed div of the user list. I have now added a key to the load more section so if the ghost spinner still happen, it should at least be pushed at the very bottom of the list.

This kind of nonsense will no longer happen in Mithirl v1+ where it's mandatory to key all children of an element if a single of of them is keyed.

I'm keeping this open for now but if there's no further report of the ghost spinner in beta 12, I'll close the issue.

clarkwinkelmann commented 3 years ago

Now that Flarum uses Mithril 2.0, this will either not happen anymore or happen for different reasons. I'm closing for now.