Skip to content

Commit 01f53ca

Browse files
authored
Fix issue with hook steps not being rendered (#379)
1 parent d06afe5 commit 01f53ca

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
## [Unreleased]
99
### Fixed
1010
- Make keyword spacing look right ([#376](https://github.com/cucumber/react-components/pull/376))
11+
- Fix issue with hook steps not being rendered ([#379](https://github.com/cucumber/react-components/pull/379))
1112

1213
### Changed
1314
- Inherit font-size instead of setting at 14px ([#377](https://github.com/cucumber/react-components/pull/377))

src/components/gherkin/GherkinDocument.stories.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import attachments from '../../../acceptance/attachments/attachments.feature.js'
66
import dataTables from '../../../acceptance/data-tables/data-tables.feature.js'
77
import examplesTables from '../../../acceptance/examples-tables/examples-tables.feature.js'
88
import hooks from '../../../acceptance/hooks/hooks.feature.js'
9+
import hooksAttachments from '../../../acceptance/hooks-attachment/hooks-attachment.feature.js'
910
import markdown from '../../../acceptance/markdown/markdown.feature.md.js'
1011
import minimal from '../../../acceptance/minimal/minimal.feature.js'
1112
import parameterTypes from '../../../acceptance/parameter-types/parameter-types.feature.js'
@@ -57,6 +58,11 @@ Hooks.args = {
5758
envelopes: hooks,
5859
}
5960

61+
export const HooksWithAttachments = Template.bind({})
62+
HooksWithAttachments.args = {
63+
envelopes: hooksAttachments,
64+
}
65+
6066
export const Markdown = Template.bind({})
6167
Markdown.args = {
6268
envelopes: markdown,

src/components/gherkin/HookStep.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const DefaultRenderer: React.FunctionComponent<HookStepProps> = ({ step }) => {
3939
)
4040
}
4141

42-
if (attachments) {
42+
if (attachments?.length) {
4343
return (
4444
<StepItem>
4545
{attachments.map((attachment, i) => (

src/components/gherkin/HookSteps.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ interface IProps {
1010
export const HookSteps: React.FunctionComponent<IProps> = ({ hookSteps }) => {
1111
return (
1212
<>
13-
{hookSteps
14-
.map((step, index) => <HookStep key={index} step={step} />)
15-
.filter((el) => !!el.props.children?.length)
16-
.map((el, index) => (
17-
<li key={index}>{el}</li>
18-
))}
13+
{hookSteps.map((step, index) => (
14+
<li key={index}>
15+
<HookStep key={index} step={step} />
16+
</li>
17+
))}
1918
</>
2019
)
2120
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
.steps {
22
padding: 0;
3-
margin: 1em;
3+
margin: 0.875em 1em;
44

55
> li {
66
list-style: none;
7-
}
87

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

0 commit comments

Comments
 (0)