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

fix #3933: Duplicated keys in PropTypes table #4095

Merged

Conversation

gombek
Copy link

@gombek gombek commented Aug 29, 2018

Issue: #3933

What I did

I've added check for duplicated lines, if line of text occur multiple times, index value will be added (as postfix) to the key.

How to test

Appropriate test is included in this PR.

@gombek gombek changed the title fix #3933: Duplicated keys in PropTypes table fix #3933: Duplicated keys in PropTypes table [bug] Aug 29, 2018
@gombek gombek changed the title fix #3933: Duplicated keys in PropTypes table [bug] fix #3933: Duplicated keys in PropTypes table ["bug"] Aug 30, 2018
@@ -19,7 +22,9 @@ export const multiLineText = input => {
lineOfText,
i // note: lineOfText is the closest we will get to a unique key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is misleading. Please remove

@@ -6,6 +6,9 @@ import { Table, Td, Th } from '@storybook/components';
import PropVal from './PropVal';
import PrettyPropType from './types/PrettyPropType';

const willItOccurAgain = (collection, item, itemIndex = 0) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason that there is a default? Seems like its always specified

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable name could also be more descriptive and declarative.

@@ -6,6 +6,9 @@ import { Table, Td, Th } from '@storybook/components';
import PropVal from './PropVal';
import PrettyPropType from './types/PrettyPropType';

const willItOccurAgain = (collection, item, itemIndex = 0) =>
collection.indexOf(item, itemIndex + 1) !== -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a bit hesitant to use this to generate a key, seems a bit unperformant and a bit of an overkill

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so maybe to simplify things, let's change key to ${lineOfText}.${i} without any check for duplicates? It won't be perfect but since this component is not heavy and not very dynamic this should be enough in this case. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be good! It'll simplify the logic which is good

@gombek gombek changed the title fix #3933: Duplicated keys in PropTypes table ["bug"] fix #3933: Duplicated keys in PropTypes table Aug 30, 2018
@codecov
Copy link

codecov bot commented Sep 3, 2018

Codecov Report

Merging #4095 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4095      +/-   ##
==========================================
+ Coverage   40.57%   40.59%   +0.02%     
==========================================
  Files         469      469              
  Lines        5641     5643       +2     
  Branches      748      749       +1     
==========================================
+ Hits         2289     2291       +2     
  Misses       2984     2984              
  Partials      368      368
Impacted Files Coverage Δ
addons/info/src/components/PropTable.js 96.29% <100%> (+0.29%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b3ef9c3...745ea7c. Read the comment docs.

@ndelangen ndelangen merged commit a2a2a91 into storybookjs:master Sep 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants