Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #271 from accordproject/dl-nav-headings
Browse files Browse the repository at this point in the history
fix(Navigation): handle empty headings
  • Loading branch information
DianaLease authored Feb 3, 2020
2 parents 1dd6e1e + 62bd6e8 commit ca3d168
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"
]
}
}
}
5 changes: 2 additions & 3 deletions src/Navigation/actions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const truncateHeading = (heading, length) => ((heading.length > length)
? `${heading.substring(0, length)}...`
: heading);
const truncateHeading = (heading, length) => ((heading && (heading.length > length))
? `${heading.substring(0, length)}...` : heading || '');

export const truncateHeader = ({ type, text }) => {
switch (type) {
Expand Down
2 changes: 2 additions & 0 deletions src/Navigation/generators.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const headerGenerator = (props) => {

return headers.map((header) => {
const { type, key } = header;
const heading = truncateHeader(header);
if (!heading) return null;
switch (type) {
case 'clause':
return (
Expand Down

0 comments on commit ca3d168

Please sign in to comment.