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

CellOptions padding does not override TableOptions padding when set to 0 #124

Closed
jennifer-shehane opened this issue Sep 13, 2019 · 0 comments · Fixed by #287
Closed

CellOptions padding does not override TableOptions padding when set to 0 #124

jennifer-shehane opened this issue Sep 13, 2019 · 0 comments · Fixed by #287

Comments

@jennifer-shehane
Copy link

jennifer-shehane commented Sep 13, 2019

If you try to override padding-left or padding-right TableOptions style with a CellOptions style with 'padding-left': 0 or 'padding-right': 0 there is no effect.

The 0 values in the cell also do not override the default padding in cli-table3.

The padding-left and padding-right set to 0 does work fine in the TableOptions however. The bug is only in overriding the Table options

const Table = require('cli-table3')

let table = new Table({
  'style': {
    'padding-left': 1, // default Table option is padding 1
  },
})

table.push([
  {
    content: 'a',
    'style': {
      'padding-left': 5,  // padding 5 👍 	
    },
  },
  {
    content: 'b',
    'style': {
      'padding-left': 1, // padding 1 👍 	
    },
  },
  {
    content: 'c',
    'style': {
      'padding-left': 0,  // padding 0 :(  no effect 	
    },
  },
  {
    content: 'd',
    'style': {
      'padding-left': -1,  // padding -1 kind of has 0 padding 
						   // but then has to offset with colWidths 2 to work
    },
  },
])

console.log(table.toString())

Resulting table:

Screen Shot 2019-09-13 at 3 36 21 PM

The tests do not cover a 0 case of padding here:

it('if set will override tableOptions.style', function() {

This line is culprit:

targetObj[nameA] = objA[nameA] || objA[nameB] || objB[nameA] || objB[nameB];

When padding-left in the Cell style options is a positive number (2) this is evaluating out as:

obj.paddingLeft = 
  cellStyleObj.paddingLeft ||      // evaluates to undefined
  cellStyleObj[padding-left] ||    // evaluates to 2
  tableStyleObj.paddingLeft ||     // evaluates to undefined
  tableStyleObj.[padding-left]     // evaluates to 1

// paddingLeft = 2 yay!!

When padding-left in the Cell style options is 0 this is evaluating out as:

obj.paddingLeft = 
  cellStyleObj.paddingLeft ||    // evaluates to undefined
  cellStyleObj[padding-left] ||  // evaluates to 0
  tableStyleObj.paddingLeft ||   // evaluates to undefined
  tableStyleObj.[padding-left]   // evaluates to 1

// paddingLeft = 1 oh no!!

I would love to submit a PR, but honestly I have no idea if I will have the time. Hopefully this is helpful!

Turbo87 pushed a commit to Turbo87/cli-table3 that referenced this issue Mar 30, 2020
Bumps [lerna-changelog](https://github.com/lerna/lerna-changelog) from 0.8.1 to 0.8.2.
<details>
<summary>Release notes</summary>

*Sourced from [lerna-changelog's releases](https://github.com/lerna/lerna-changelog/releases).*

> ## v0.8.2
> #### 🐛 Bug Fix
> * [cli-table#125](https://github-redirect.dependabot.com/lerna/lerna-changelog/pull/125) Fix `nextVersion` config handling ([[**Turbo87**](https://github.com/Turbo87)](https://github.com/Turbo87))
> 
> #### 🏠 Internal
> * [cli-table#124](https://github-redirect.dependabot.com/lerna/lerna-changelog/pull/124) yarn: Add `integrity` hashes ([[**Turbo87**](https://github.com/Turbo87)](https://github.com/Turbo87))
> 
> #### Committers: 1
> - Tobias Bieniek ([[**Turbo87**](https://github.com/Turbo87)](https://github.com/Turbo87))
</details>
<details>
<summary>Changelog</summary>

*Sourced from [lerna-changelog's changelog](https://github.com/lerna/lerna-changelog/blob/master/CHANGELOG.md).*

> ## v0.8.2 (2018-10-14)
> 
> #### 🐛 Bug Fix
> * [cli-table#125](https://github-redirect.dependabot.com/lerna/lerna-changelog/pull/125) Fix `nextVersion` config handling ([[**Turbo87**](https://github.com/Turbo87)](https://github.com/Turbo87))
> 
> #### 🏠 Internal
> * [cli-table#124](https://github-redirect.dependabot.com/lerna/lerna-changelog/pull/124) yarn: Add `integrity` hashes ([[**Turbo87**](https://github.com/Turbo87)](https://github.com/Turbo87))
> 
> #### Committers: 1
> - Tobias Bieniek ([[**Turbo87**](https://github.com/Turbo87)](https://github.com/Turbo87))
</details>
<details>
<summary>Commits</summary>

- [`8ae7803`](lerna/lerna-changelog@8ae7803) v0.8.2
- [`01ac435`](lerna/lerna-changelog@01ac435) Update Changelog
- [`17b2a9c`](lerna/lerna-changelog@17b2a9c) Merge pull request [cli-table#125](https://github-redirect.dependabot.com/lerna/lerna-changelog/issues/125) from Turbo87/config-fix
- [`dfe0b1d`](lerna/lerna-changelog@dfe0b1d) Fix `nextVersion` config handling
- [`958dc28`](lerna/lerna-changelog@958dc28) Merge pull request [cli-table#124](https://github-redirect.dependabot.com/lerna/lerna-changelog/issues/124) from Turbo87/integrity
- [`e135748`](lerna/lerna-changelog@e135748) yarn: Add `integrity` hashes
- See full diff in [compare view](lerna/lerna-changelog@v0.8.1...v0.8.2)
</details>
<br />

[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=lerna-changelog&package-manager=npm_and_yarn&previous-version=0.8.1&new-version=0.8.2)](https://dependabot.com/compatibility-score.html?dependency-name=lerna-changelog&package-manager=npm_and_yarn&previous-version=0.8.1&new-version=0.8.2)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

Dependabot will **not** automatically merge this PR because this dependency is pre-1.0.0.

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)

Finally, you can contact us by mentioning @dependabot.

</details>
speedytwenty added a commit to speedytwenty/cli-table3 that referenced this issue Apr 1, 2022
@speedytwenty speedytwenty linked a pull request Apr 1, 2022 that will close this issue
speedytwenty added a commit to speedytwenty/cli-table3 that referenced this issue Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant