Skip to content
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

Toolbar table sort script interfering with project tables in development environment #6808

Closed
mmlTools opened this issue Nov 2, 2022 · 9 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@mmlTools
Copy link

mmlTools commented Nov 2, 2022

PHP Version

7.4

CodeIgniter4 Version

4.2.8

CodeIgniter4 Installation Method

Manual (zip or tar.gz)

Which operating systems have you tested for this bug?

Windows, Linux

Which server did you use?

apache

Database

MySQL 5.6

What happened?

Toolbar table sort script interfering with project tables in development environment.

Steps to Reproduce

1.Set environment to development
2.Create a table with headers as for example

<table>
<thead>
<tr><th>Col1</th><th>Col2</th></tr>
<thead>
<tbody>
<tr><td>1</td><td>a</td></tr>
<tr><td>2</td><td>b</td></tr>
<tr><td>3</td><td>d</td></tr>
</tbody>
<table>

3.Click on any of the table headers and the table will be sorted

Expected Output

This shouldn't happen because is interfering with custom table sort scripts.

Anything else?

No response

@mmlTools mmlTools added the bug Verified issues on the current code behavior or pull requests that will fix them label Nov 2, 2022
@kenjis
Copy link
Member

kenjis commented Nov 2, 2022

I confirmed the bug.

<?php

namespace App\Controllers;

class Home extends BaseController
{
    public function index()
    {
        return '<table>
<thead>
<tr><th>Col1</th><th>Col2</th></tr>
<thead>
<tbody>
<tr><td>100</td><td>a</td></tr>
<tr><td>2</td><td>b</td></tr>
<tr><td>3</td><td>d</td></tr>
</tbody>
<table>';
    }
}

@kenjis
Copy link
Member

kenjis commented Nov 2, 2022

This feature is provided by Kint.
You can disable Kint, but a bug that outputs "0" when you disable Kint.
See #6809

@mmlTools
Copy link
Author

mmlTools commented Nov 2, 2022

This feature is provided by Kint. You can disable Kint, but a bug that outputs "0" when you disable Kint. See #6809

Created a hackfix that is not causing any errors.

  1. Go to system\ThirdParty\Kint\resources\compiled\rich.js and beautify this js file
  2. In line 183 comment the following
else
     e.ctrlKey || l.sortTable(t.parentNode.parentNode.parentNode, t.cellIndex)
  1. Use this instead
else if($(t.closest('#debug-bar')).length)
                l.sortTable(t.parentNode.parentNode.parentNode, t.cellIndex)
            else
                e.ctrlKey

This will check if parent element is our debug bar.

@erikkraijenoord
Copy link

Exactly the same happend to me, thank you for the provided information!

@kenjis
Copy link
Member

kenjis commented Nov 3, 2022

I don't know the details.
Why does toolbar outputs Kint's js?
Does toolbar use it?

And we cannot patch Kint. If Kint's js breaks our apps, it seems to be a bug in Kint.

@paulbalandan paulbalandan changed the title Bug: Toolbar table sort script interfering with project tables in development environment Toolbar table sort script interfering with project tables in development environment Nov 9, 2022
@paulbalandan
Copy link
Member

Closing as this is not a bug of the framework.

@kenjis
Copy link
Member

kenjis commented Nov 9, 2022

@paulbalandan Do you know why toolbar outputs Kint's js?

@paulbalandan
Copy link
Member

This is because of this line:

$varData[esc($key)] = $kint;

If we passed data to view(), those will be shown in the toolbar. If the passed data is an object, for example, the line above will create a Kint representation of the object similar to d()'s output, so it needs rendering.

@paulbalandan
Copy link
Member

<?php

namespace App\Controllers;

class Home extends BaseController
{
    public function index()
    {
        return view('welcome_message', ['home' => new self]);
    }
}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

4 participants