php-debugbar icon indicating copy to clipboard operation
php-debugbar copied to clipboard

Selecting first dataset to display by default in the debugbar UI

Open niteshn opened this issue 11 years ago • 10 comments

On a page with multiple ajax calls, I want the first dataset (First request) to be selected by default. Right now the last request is selected by default.

How can we achieve this ?

niteshn avatar Apr 17 '14 13:04 niteshn

should be very easy and a good default. will change that

maximebf avatar Apr 24 '14 14:04 maximebf

Or a checkbox/toggle, to indicate you want to load the latest requests, or stay on the first on. When loading a page, I usually want to see the real page and not the ajax calls. But when I click on something after a few seconds, I'd rather see the new requests. Not really sure what would be the best default :P

barryvdh avatar Apr 24 '14 14:04 barryvdh

I would select the first one on load but subsequent ajax calls are automatically selected. Is that ok?

Maxime

On Thu, Apr 24, 2014 at 9:57 AM, Barry vd. Heuvel [email protected]:

Or a checkbox/toggle, to indicate you want to load the latest requests, or stay on the first on. When loading a page, I usually want to see the real page and not the ajax calls. But when I click on something after a few seconds, I'd rather see the new requests. Not really sure what would be the best default :P

— Reply to this email directly or view it on GitHubhttps://github.com/maximebf/php-debugbar/issues/120#issuecomment-41290102 .

maximebf avatar Apr 24 '14 15:04 maximebf

What does "subsequent ajax calls" mean exactly ? After page load and onload ajax calls, if I click somewhere and an ajax call happens, then it should probably be selected automatically. Anything is fine actually. Important thing being that real page should be visible by default on page load. thanks.

niteshn avatar Apr 24 '14 17:04 niteshn

I was looking into that and it seems harder than it looked at first. I don't know if an ajax call is triggered on page load or due to a click event so I cannot know when to auto-show a request or not. To know the origin of an ajax request, it would be needed to indicate everywhere whether to show it or not which would be cumbersome. At the moment I'm leaving the default as is but adding the possibility to show or not a request when it is added to the debugbar in the api. The checkbox idea will propably be the best option I think.

maximebf avatar Jul 26 '14 14:07 maximebf

:+1: for the checkbox. If it is checked, it stays on the currently selected item in the select, otherwise it shows up the latest received dataset.

tomzx avatar Aug 01 '14 16:08 tomzx

Has this been fixed yet? This is a really frustrating problem on pages that have constant automatic AJAX requests.

vdh avatar Nov 02 '15 05:11 vdh

Has this been fixed yet?

bugyak avatar Mar 02 '17 03:03 bugyak

This bug was bothering me, so I made a quick and dirty solution that overrides the js method addDataSet:

<script>
// Copied from the source with a single line commented out
PhpDebugBar.DebugBar.prototype.addDataSet = function(data, id, suffix) {
    var label = this.datesetTitleFormater.format(id, data, suffix);
    id = id || (getObjectSize(this.datasets) + 1);
    this.datasets[id] = data;

    this.$datasets.append($('<option value="' + id + '">' + label + '</option>'));
    if (this.$datasets.children().length > 1) {
        this.$datasets.show();
    }

    // The below line was commented out to prevent automatic switching to ajax requests
    // this.showDataSet(id);
    return id;
};
</script>

If you place the above script below your $renderer->render() output, it will only take effect after the initial page load. So, if you have stacked requests from a redirect it will show the latest one, but then it won't switch automatically anymore for future ajax requests.

jdorn avatar Mar 13 '17 03:03 jdorn

As far as I can see it manageable with autoShow value now.

sauron918 avatar Apr 16 '19 12:04 sauron918