Skip to content

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

Closed
@jaydiablo

Description

@jaydiablo
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions