8000 [Console] Using TableCell with colspan and certain styles doesn't render properly · Issue #21434 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console] Using TableCell with colspan and certain styles doesn't render properly #21434

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

Closed
jaydiablo opened this issue Jan 27, 2017 · 2 comments

Comments

@jaydiablo
Copy link
Contributor
jaydiablo commented Jan 27, 2017
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 2.7+

I'm not sure how to write a test for this, as I don't know the best way to test for colors in the console component, but here's an example that shows the behavior that I'm talking about:

'Header with comment style' => array(
                array(
                    new TableCell('<comment>Long Title</comment>', array('colspan' => 3)),
                ),
                array(
                    array(
                        new TableCell('9971-5-0210-0', array('colspan' => 3)),
                    ),
                    new TableSeparator(),
                    array(
                        'Dante Alighieri',
                        'J. R. R. Tolkien',
                        'J. R. R'
                    ),
                ),
                'default',
<<<'TABLE'
+------------------+---------+------------------+
| Long Title                                    |
+------------------+---------+------------------+
| 9971-5-0210-0                                 |
+------------------+---------+------------------+
| Dante Alighieri  | J. R. R. Tolkien | J. R. R |
+------------------+---------+------------------+

TABLE
            ),

(in order to make this fail in the symfony test suite I have to enable the $decorator parameter in the method getOutputStream())

Here's how that table renders:

screen shot 2017-01-27 at 9 25 55 am

If I don't use <comment> as the style, and use the <fg> type of style, it works as expected:

),
            'Header with comment style' => array(
                array(
                    new TableCell('<fg=yellow>Long Title</>', array('colspan' => 3)),
                ),
                array(
                    array(
                        new TableCell('9971-5-0210-0', array('colspan' => 3)),
                    ),
                    new TableSeparator(),
                    array(
                        'Dante Alighieri',
                        'J. R. R. Tolkien',
                        'J. R. R'
                    ),
                ),
                'default',
<<<'TABLE'
+------------------+---------+------------------+
| Long Title                                    |
+------------------+---------+------------------+
| 9971-5-0210-0                                 |
+------------------+---------+------------------+
| Dante Alighieri  | J. R. R. Tolkien | J. R. R |
+------------------+---------+------------------+

TABLE
            ),

Output:

screen shot 2017-01-27 at 9 28 22 am

The <error> style also fails:

screen shot 2017-01-27 at 9 29 45 am

So does the <question> style:

screen shot 2017-01-27 at 9 32 40 am

But the <info> style is fine (I assume this is the default for the header rows):

screen shot 2017-01-27 at 9 30 24 am

This doesn't happen if there is no colspan:

'Header with comment style' => array(
                array(
                    new TableCell('<comment>Long Title</comment>'),
                    'Test',
                    'Test'
                ),
                array(
                    array(
                        new TableCell('9971-5-0210-0', array('colspan' => 3)),
                    ),
                    new TableSeparator(),
                    array(
                        'Dante Alighieri',
                        'J. R. R. Tolkien',
                        'J. R. R'
                    ),
                ),
                'default',
<<<'TABLE'
+------------------+---------+------------------+
| Long Title       | Test             | Test    |
+------------------+---------+------------------+
| 9971-5-0210-0                                 |
+------------------+---------+------------------+
| Dante Alighieri  | J. R. R. Tolkien | J. R. R |
+------------------+---------+------------------+

TABLE
            ),

Output:

screen shot 2017-01-27 at 9 35 46 am

Position of the Cell with the style doesn't seem to matter, so I think it's just setting a colspan that causes it to color the whole table:

'Header with comment style' => array(
                array(
                    'Test',
                    'Test',
                    new TableCell('<comment>Long Title</comment>'),
                ),
                array(
                    array(
                        new TableCell('9971-5-0210-0', array('colspan' => 3)),
                    ),
                    new TableSeparator(),
                    array(
                        'Dante Alighieri',
                        'J. R. R. Tolkien',
                        'J. R. R'
                    ),
                ),
                'default',
<<<'TABLE'
+------------------+---------+---------------------+
| Test             | Test             | Long Title |
+------------------+---------+---------------------+
| 9971-5-0210-0                                    |
+------------------+---------+---------------------+
| Dante Alighieri  | J. R. R. Tolkien | J. R. R    |
+------------------+---------+---------------------+

TABLE
            ),

Output:

screen shot 2017-01-27 at 9 37 48 am

@jaydiablo jaydiablo changed the title [Console] Using TableCell with rowspan and certain styles doesn't render properly [Console] Using TableCell with colspan and certain styles doesn't render properly Jan 27, 2017
@jaydiablo
Copy link
Contributor Author

FWIW, this is what gets passed to the formatter:

|<info> <comment>Long Title</comment> </info>|

Which renders like so in the Formatter (notice that the pipes are also yellow):

screen shot 2017-01-27 at 10 10 21 am

When I remove the colspan (and add a couple of rows) this is the content passed to the formatter:

|<info> <comment>Long Title</comment> </info>|<info> Test </info>|<info> Test </info>|

Which renders like so:

screen shot 2017-01-27 at 10 09 45 am

So it doesn't seem to be a nested tag issue, I'm not yet clear why these two different string are rendered differently.

@ogizanagi
Copy link
Contributor
ogizanagi commented Jan 27, 2017

Thanks for all the inputs you've provided to help reproducing and debugging this issue. I was able to reproduce the issue, and noticed it worked for

new TableCell('<comment>Long Title</>')

while it doesn't for

new TableCell('<comment>Long Title</comment>')

Nothing is wrong with the short or long closing tag, but the main difference is the length.
It appears using a TableCell didn't properly inspect the content length, as it may contain some styles. Then Helper::strlenWithoutDecoration should be used.

See #21438

nicolas-grekas added a commit that referenced this issue Jan 29, 2017
This PR was merged into the 2.7 branch.

Discussion
----------

[Console] Fix TableCell issues with decoration

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes (failure unrelated)
| Fixed tickets | #21434
| License       | MIT
| Doc PR        | N/A

Commits
-------

50373f3 [Console] Fix TableCell issues with decoration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0