Redocly / Redocly/redoc

Bug: showFoldingButtons returns values instead of hiding buttons

Open
#2,219 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
25.9k
Forks
2.4k
Avg merge
13h 10m
Merged PRs (30d)
4

Description

https://github.com/Redocly/redoc/blob/16f542bbfe856e5ae5eb40636ac79421fa2f397b/src/components/JsonViewer/JsonViewer.tsx#L26

For falsey values (e.g. data = 0) this expression (data && condition) will return data (e.g. 0). This won't happen if it were to return strictly boolean values:
const showFoldingButtons = Boolean(props.data && Object.values(props.data).some(value => typeof value === 'object' && value !== null));

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open src/components/JsonViewer/JsonViewer.tsx at the referenced showFoldingButtons expression and verify how falsey data such as 0 is handled. Make the result strictly boolean as described in the issue, then confirm that folding buttons are hidden for falsey data and shown when nested object values exist.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.