Skip to content

Fix issue with hook steps not being rendered #379

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

Merged
merged 5 commits into from
Apr 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
### Fixed
- Make keyword spacing look right ([#376](https://github.com/cucumber/react-components/pull/376))
- Fix issue with hook steps not being rendered ([#379](https://github.com/cucumber/react-components/pull/379))

### Changed
- Inherit font-size instead of setting at 14px ([#377](https://github.com/cucumber/react-components/pull/377))
Expand Down
6 changes: 6 additions & 0 deletions src/components/gherkin/GherkinDocument.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import attachments from '../../../acceptance/attachments/attachments.feature.js'
import dataTables from '../../../acceptance/data-tables/data-tables.feature.js'
import examplesTables from '../../../acceptance/examples-tables/examples-tables.feature.js'
import hooks from '../../../acceptance/hooks/hooks.feature.js'
import hooksAttachments from '../../../acceptance/hooks-attachment/hooks-attachment.feature.js'
import markdown from '../../../acceptance/markdown/markdown.feature.md.js'
import minimal from '../../../acceptance/minimal/minimal.feature.js'
import parameterTypes from '../../../acceptance/parameter-types/parameter-types.feature.js'
Expand Down Expand Up @@ -57,6 +58,11 @@ Hooks.args = {
envelopes: hooks,
}

export const HooksWithAttachments = Template.bind({})
HooksWithAttachments.args = {
envelopes: hooksAttachments,
}

export const Markdown = Template.bind({})
Markdown.args = {
envelopes: markdown,
Expand Down
2 changes: 1 addition & 1 deletion src/components/gherkin/HookStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const DefaultRenderer: React.FunctionComponent<HookStepProps> = ({ step }) => {
)
}

if (attachments) {
if (attachments?.length) {
return (
<StepItem>
{attachments.map((attachment, i) => (
Expand Down
11 changes: 5 additions & 6 deletions src/components/gherkin/HookSteps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ interface IProps {
export const HookSteps: React.FunctionComponent<IProps> = ({ hookSteps }) => {
return (
<>
{hookSteps
.map((step, index) => <HookStep key={index} step={step} />)
.filter((el) => !!el.props.children?.length)
.map((el, index) => (
<li key={index}>{el}</li>
))}
{hookSteps.map((step, index) => (
<li key={index}>
<HookStep key={index} step={step} />
</li>
))}
</>
)
}
8 changes: 4 additions & 4 deletions src/components/gherkin/StepsList.module.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.steps {
padding: 0;
margin: 1em;
margin: 0.875em 1em;

> li {
list-style: none;
}

> li + li {
margin-top: 0.25em;
&:not(:empty) {
padding: 0.125em 0;
}
}
}