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

Debugbar adding a 8px margin-bottom on <body> when enabled

Open devsquad-victor-lima opened this issue 2 years ago • 5 comments

Steps to reproduce:

  1. Activate Debugbar
  2. Open any page in your project
  3. Open Devtools and you should see the margin-bottom appended on tag

image

Please let me know if it is actually needed for the bar to work or if I am doing something wrong with some setting.

Thank you!

devsquad-victor-lima avatar Nov 25 '22 00:11 devsquad-victor-lima

@devsquad-victor-lima

This is from the parent project PHP Debug Bar

https://github.com/maximebf/php-debugbar/blob/1c2a5300cc1f99ef60dc17449a20e0b345d564f5/src/DebugBar/Resources/debugbar.js#L850

/**
 * Recomputes the margin-bottom css property of the body so
 * that the debug bar never hides any content
 */
recomputeBottomOffset: function() {
    if (this.options.bodyMarginBottom) {
        if (this.isClosed()) {
            return $('body').css('margin-bottom', this.options.bodyMarginBottomHeight || '');
        }

        var offset = parseInt(this.$el.height()) + (this.options.bodyMarginBottomHeight || 0);
        $('body').css('margin-bottom', offset);
    }
},

leettaylor avatar Dec 02 '22 11:12 leettaylor

I hate that margin. Is there a way to disable it?

Jacobtims avatar Dec 06 '22 17:12 Jacobtims

@Jacobtims Doesn't look like it can be disabled. There's a bodyMarginBottom option that is always set to to true.

https://github.com/maximebf/php-debugbar/blob/1c2a5300cc1f99ef60dc17449a20e0b345d564f5/src/DebugBar/Resources/debugbar.js#L413

options: {
    bodyMarginBottom: true,
    bodyMarginBottomHeight: 0
},

You could try adding a PR to that project with an option to disable bodyMarginBottom.

leettaylor avatar Dec 07 '22 08:12 leettaylor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Jun 18 '23 15:06 stale[bot]

Add this at the end of the body tag:

@if (config('app.debug'))
    <script>
        PhpDebugBar.DebugBar.prototype.recomputeBottomOffset = () => {};
    </script>
@endif

piotrjoniec avatar Dec 16 '23 19:12 piotrjoniec