-
Notifications
You must be signed in to change notification settings - Fork 350
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(chip group): add prop to allow chip group to be initially expanded #2651
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0867c91
fix(chip group): add prop for an override which allows chip group to …
jenny-s51 bd30f9b
removes unnecessary imports and updates snapshot tests
jenny-s51 284df7e
fix(chipgroup): renaming isOpenOnInit to defaultIsOpen
jenny-s51 6d6f9a1
fix(chipgroup): add new prop to demo and integration
jenny-s51 c80530f
fix(chipgroup): adding separate demo and cypress test for new prop
jenny-s51 ce46f08
fix(chipgroup): renaming cypress test to match other instances
jenny-s51 c4dda17
fix(chipgroup demo): fixed test check
jenny-s51 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/patternfly-4/react-integration/cypress/integration/chipgroupdefaultisopen.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
describe('Chip Group Demo Test', () => { | ||
it('Navigate to demo section', () => { | ||
cy.visit('http://localhost:3000/'); | ||
cy.get('#chipgroup-default-is-open-demo-nav-item-link').click(); | ||
cy.url().should('eq', 'http://localhost:3000/chipgroup-default-is-open-demo-nav-link'); | ||
}); | ||
|
||
it('Verify chip default text', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't we be verifying the chip group is open? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, nice catch! fixed it 👍 |
||
cy.get('.pf-c-chip__text').first().contains('Lemons'); | ||
}); | ||
|
||
it('Verify chip is open on default', () => { | ||
cy.get('.pf-c-chip__text').eq(1).contains('Limes'); | ||
}); | ||
|
||
it('Verify chip has badge', () => { | ||
cy.get('span').children('.pf-c-badge').should('not.be.undefined'); | ||
cy.get('span').children('.pf-c-badge').should('not.equal', null); | ||
}); | ||
|
||
it('Verify show less button works', () => { | ||
cy.get('.pf-m-overflow').children('button').click(); | ||
cy.get('.pf-c-chip__text').contains('more') | ||
}); | ||
|
||
it('Verify more button works', () => { | ||
cy.get('.pf-m-overflow').children('button').click(); | ||
cy.get('.pf-c-chip__text').contains('Show Less') | ||
}); | ||
|
||
it('Verify delete button on first chip', () => { | ||
const chip = cy.get('.pf-c-chip').children('#pf-random-id-0') | ||
cy.get('#remove_pf-random-id-0').click(); | ||
chip.should('not.exist') | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...integration/demo-app-ts/src/components/demos/ChipGroupDemo/ChipGroupDefaultIsOpenDemo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Badge, Chip, ChipGroup } from '@patternfly/react-core'; | ||
import React, { Component } from 'react'; | ||
|
||
interface BadgeChipState { | ||
badgeChipArray: Array< | ||
{ | ||
name: string, | ||
isRead: boolean, | ||
count: number | ||
}> | ||
} | ||
|
||
export class ChipGroupDefaultIsOpenDemo extends Component<{}, BadgeChipState> { | ||
deleteItem: (id: any) => void; | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
badgeChipArray: [ | ||
{ | ||
name: 'Lemons', | ||
isRead: true, | ||
count: 10 | ||
}, | ||
{ | ||
name: 'Limes', | ||
isRead: true, | ||
count: 8 | ||
} | ||
] | ||
}; | ||
this.deleteItem = (id: any) => { | ||
const copyOfbadgeChipArray = this.state.badgeChipArray; | ||
const index = copyOfbadgeChipArray.findIndex(chipObj => chipObj.name === id); | ||
|
||
if (index !== -1) { | ||
copyOfbadgeChipArray.splice(index, 1); | ||
this.setState({ badgeChipArray: copyOfbadgeChipArray }); | ||
} | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
window.scrollTo(0, 0) | ||
} | ||
|
||
render() { | ||
const { badgeChipArray } = this.state; | ||
return ( | ||
<ChipGroup defaultIsOpen> | ||
{badgeChipArray.map(chip => ( | ||
<Chip key={chip.name} onClick={() => this.deleteItem(chip.name)}> | ||
{chip.name} | ||
<Badge isRead={chip.isRead}>{chip.count}</Badge> | ||
</Chip> | ||
))} | ||
</ChipGroup> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need
this.
, butsuper(props)
does setthis.props
so you're fine :)