Fixes #12447

When a table is in a panel, only remove top and bottom border if it's the first or last row respectively