table icon indicating copy to clipboard operation
table copied to clipboard

Headers in Table don't calculate the size correctly if using emoticons like "๐Ÿงช"

Open mastrzyz opened this issue 3 years ago โ€ข 0 comments

For some reason with the following code :

const baseColumns = [
  ["๐Ÿงชaaaa", ""],
  ["A", "B"]
];

const config = {
  spanningCells: [{ col: 0, row: 0, colSpan: 2 }]
};

console.log(table(baseColumns, config));

We get the following error from table : subjectWidth: 6 , containerwidth:5 node_modules/table/dist/src/alignString.js

    if (subjectWidth > containerWidth) {
        throw new Error('Subject parameter value width cannot be greater than the container width.');
    }

This does not repro if I remove the emoticon

const baseColumns = [
  ["aaaaaaaaaaaaaaaaaaaaaa", ""],
  ["A", "B"]
];

const config = {
  spanningCells: [{ col: 0, row: 0, colSpan: 2 }]
};

console.log(table(baseColumns, config));

output.

โ•”โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ aaaaa โ•‘
โ•‘ aaaaa โ•‘
โ•‘ aaaaa โ•‘
โ•‘ aaaaa โ•‘
โ•‘ aa    โ•‘
โ•Ÿโ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ•ข
โ•‘ A โ”‚ B โ•‘
โ•šโ•โ•โ•โ•งโ•โ•โ•โ•

Note this also repros if I use colSpan instead of header.

mastrzyz avatar Sep 15 '22 01:09 mastrzyz