-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
parent components (i) do not refresh children html and (ii) break when used as direct views #662
Comments
@adamghill sorry to keep blowing up your repo with long-winded issues 😅. This one in particular is holding back my team's apps, so let me know if there's a way I can sponsor it to help bump it in your priority list |
No worries! Much better to have a lot of details so I can reproduce the errors, so thank you! I'm going to take a look at this today and see if I can figure out what is going on. I will let you know. 👍 |
Ok, I think there are two things going on for issue 1:
Here you can see after I made those changes, things seem to work as expected: Let me know if you run into any other problems or what I said above doesn't make sense!
I should also add a warning to the docs about HTML comments at the top of a component template since that has bitten me before as well. Even better, it would be nice to figure out how to handle that so it doesn't cause an issue at all. I'll dig into this some more today. I have not checked into issue 2 yet, but I'll look into it next. |
Just verified that issue 2 still occurs even with the fixes I laid out above. So, there must be something going on with the direct view. I'll let you know what I find. |
Awesome! I didn't see this in the docs, so thank you. Once I added this and removed my comments, issue 1 is fixed!!
Let me know what you think of these two ideas for helping users avoid this:
|
I think I have solved for all of these issues in #663. Interestingly in my testing now, having the HTML comment at the top of a component does not seem to be a problem. I could have sworn it was causing an issue of some kind, but it might have been a red herring, so apologies if that caused any concern for you! I am going to try to get another PR mergeable for this release, but should get a new version published by the end of this weekend. |
awesome!! Thank you for doing this so quickly 😄 |
This got fixed in 0.60.0. |
Sorry to do this... But it's looking like issue 2 was only silenced & replaced with a new bug. After refreshing the page of a direct view, I think the component cache isn't grabbing the correct object. What happens in the official example is that the filter component does not take any input (and incorrectly see's filter staying at You can see after the refresh that nothing from my 2nd search reaches the backend |
Ok, thanks for letting me know. I'll take a look when I can. |
Thanks 😄 This line might need to be re-added by the way: Without it, changes from # in urls.py
urlpatterns = [
# .....
path(
route="example/<pk>", # Note the <pk> here
view=components.ExampleView.as_view(),
name="example",
),
] # in component/example.py
class ExampleView(UnicornView):
def mount(self):
# URL arguments are stored under self.kwargs
# and it is only available in the first direct view
self.target = CortevaTarget.objects.get(id=self.kwargs["pk"]) So on page load I am using the url kwarg This works normally in 0.59.0, but throws errors in 0.60.0. I was able to fix this by just re-adding your line |
Seems like I'm causing a lot of headache by trying to use direct views. If you think this will take a while to fix, let me know and I'll switch back to normal components 😅 |
Yeah. 😅 That line directly causes the previous error, so I need to dig into the caching context manager to figure out what to do.
Fixing this bug is my highest priority, but I don't have a good sense of how long it'll take -- I spent a decent amount of time the other day debugging the original problem. Might be best to skip direct views for now so you are unblocked, at least. I'll let you know what I find. |
I'm seeing that the initial page works properly and there is no longer an error after refreshing -- however it doesn't look like any message calls are reaching the backend after the refresh: I'm not seeing any of the ajax requests send from the frontend after the refresh either: Here's my test case btw: |
This could probably be two separate github issues, but I keep them together just to make things easier. I break them into section below though.
I've reproduced these errors in several environments:
And I'm using Chrome for my browser
issue 1: html not refreshing
I was struggling with this in a personal project, so I went back and was actually able to reproduce the issue with the example from the docs. I built the parent component from this example in the docs exactly, and only added one line:
Here are the minimal django project files. Note, sqlite file has everything loaded already, so you can just use
python manage.py runserver
to run the app:mysite_example1.zip
Once on the
books/
page, you can see that the unicorn calls & backend is working as expected but the page doesn't refresh:No matter what I try, I can't get the html to update when the
filter
component is used.issue 2: parent components can't be direct views
This is the exact same app as before, except I'm using
TableView.as_view()
instead of adding the component to anindex.html
:mysite_example2.zip
When you first spin up your django server, the view works as expected (except for what I describe in issue 1). However, once the page is refreshed and used a 2nd time, the page fails and cannot be loaded:
^^ note in the logs that this happens after a page refresh. This is consistent and happening in my personal project as well.
Here's the full error traceback:
The text was updated successfully, but these errors were encountered: