-
Notifications
You must be signed in to change notification settings - Fork 1k
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
1843 new ajax request resets whole view if historypanel is enabled #1872
1843 new ajax request resets whole view if historypanel is enabled #1872
Conversation
[m] If history panel is activated and one previous request has been switched on any xhr or fetch will reset the whole view [m] The history panel is updated on click on the history button
[+] Create a settings which enable or disable the automatic refresh when an ajax request occurs
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
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.
Thank you for working on this!
@@ -19,6 +19,7 @@ const djdt = { | |||
handleDragged: false, | |||
init() { | |||
const djDebug = getDebugElement(); | |||
window.djdt.update_on_ajax = djDebug.getAttribute("update-on-ajax") === "True"; |
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.
It's not completely consistent but we generally prefer using camelCase
in JavaScript code.
Also, other parts of the code use the dataset attribute, so this should be djDebug.dataset.updateOnAjax
and data-update-on-ajax
(or whatever the name of the attribute is). A data-
prefix for attributes is a good idea anyway because such attributes are always valid HTML.
I wonder if there is a better place for this property though. Tim suggested using localStorage to allow switching between the auto update and manual update behavior on the fly, and this probably wouldn't work with the way it's proposed here. Also, I don't think we want to expose the attribute to external modification (just yet). Putting it in the same place as the handleDragged
property may be a good idea?
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.
Tim suggested using localStorage to allow switching between the auto update and manual update behavior on the fly, and this probably wouldn't work with the way it's proposed here.
For some context, when Elineda and I spoke yesterday, we decided we could start with a settings control. If we find that it doesn't meet developers needs, we can add the JS to make it more stateful.
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.
Makes sense!
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.
I did change asked, but I don't put on a localstorage, I just with handleDragged.
…le-view-if-historypanel-is-enabled' into 1843-new-ajax-request-resets-whole-view-if-historypanel-is-enabled
…istorypanel-is-enabled
for more information, see https://pre-commit.ci
@matthiask can you review the documentation suggestions? |
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.
I like it! Only small suggestions this time.
@@ -16,7 +16,7 @@ | |||
data-sidebar-url="{{ history_url }}" | |||
{% endif %} | |||
data-default-show="{% if toolbar.config.SHOW_COLLAPSED %}false{% else %}true{% endif %}" | |||
{{ toolbar.config.ROOT_TAG_EXTRA_ATTRS|safe }}> | |||
{{ toolbar.config.ROOT_TAG_EXTRA_ATTRS|safe }} data-update-on-fetch="{{ toolbar.config.UPDATE_ON_FETCH|safe }}"> |
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.
{{ toolbar.config.ROOT_TAG_EXTRA_ATTRS|safe }} data-update-on-fetch="{{ toolbar.config.UPDATE_ON_FETCH|safe }}"> | |
{{ toolbar.config.ROOT_TAG_EXTRA_ATTRS|safe }} data-update-on-fetch="{{ toolbar.config.UPDATE_ON_FETCH }}"> |
I'm not 100% sure but I don't think |safe
is necessary.
Also, you could use |yesno:'true,false'
or do it as data-default-show
so that the value is lowercased already, but I'm just suggesting that, not asking for anything.
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.
I removed safe. But I didn't used yesno because the result of this will be a string and we will need do to the same things in js for checking it, lowercased or not.
[m] Remove safe on data-update-on-fetch attribute [m] Put the new settings as False as default like intended
[t] Add a sleep on a selenium for prevent failure
[t] Add a sleep on a selenium for prevent failure
@matthiask I'm realizing I broke from our typical merge process. @elineda asked in private if she could merge, I said yes. |
@tim-schilling No worries. I was a little bit surprised but also relieved. I think merging faster is fine, really, especially in Jazzband. |
This is a great change, thanks @elineda! I did notice that this seems to duplicate the functionality of the |
I went back and read the discussion in #1577 I think I agree with your assessment. I remember that I had some problems understanding what |
OK, so I just played around with this feature some more, and either I'm doing something wrong, or it is not working the way I expect. I confirmed that I have DjDT 4.3.0 using the Versions panel, and I have an explicit I am currently able to achieve that desired behavior by including |
|
@living180 I can't reproduce the issue you're describing. When I run |
Sure, it's late where I am, but I'll try to reproduce with a simpler example hopefully tomorrow. |
OK, turns out the problem on my end was caused by stale cached JavaScript files for the Debug Toolbar. After a force refresh in my browser,
I think |
|
Unless I'm really reading something wrong, In that case the which is only called by So no matter how This also means that the default definition of |
Ack, good point. I wasn't digging deep enough. I agree that with the new setting, we could direct people to using |
I appreciate this enhancement, but very curious why the default is set to False when the historical behavior has been to update with an ajax request? If someone (me) misses this in the changelog, it can make for an annoying hour of troubleshooting. Forget beginner friendly, this is not a developer friendly attitude at all. |
There wasn't a great choice for us here. Your experience is the worse case for changing the default. However, that's less worse than the original bug request where the default cause hijacks the toolbar without consent. I'm sorry you had to deal with the difficult consequences of that choice. |
The release notes could have better called it out though. |
If I'm remember well, this pr was the reason to not put a minor version on this release. |
Thanks for your feedback. You're very welcome to submit a concrete proposal how this could have been handled better and I'd certainly appreciate that. That being said, in my personal opinion the previous behavior wasn't friendly to the development experience of myself and others. Also, all defaults are bad for some subset of users. |
Description
[+] Create a setting which enable or disable the automatic refresh when an ajax request occurs.
Fixes #1843
Checklist:
docs/changes.rst
.