Skip to content

Do not render in AddDetail when visibility is disabled - #242

Closed
AdamMagued wants to merge 1 commit into
schollz:mainfrom
AdamMagued:fix-invisible-adddetail
Closed

AdamMagued wants to merge 1 commit into
schollz:mainfrom
AdamMagued:fix-invisible-adddetail

Conversation

@AdamMagued

Copy link
Copy Markdown

Summary

When a progress bar is configured with OptionSetVisibility(false), calling AddDetail would inadvertently render the progress bar to the output writer if state.details was nil. In addition, ProgressBar.render() lacked an explicit check for config.invisible.

Root Cause

In progressbar.go, AddDetail attempts to render the progress bar prior to attaching the initial detail row if p.state.details == nil. However, this call to p.render() was executed unconditionally without checking p.config.invisible. Furthermore, p.render() itself did not guard against p.config.invisible like other methods (Add64, RenderBlank, Describe, renderDetails).

Changes

  1. Guard p.render() call in AddDetail with if !p.config.invisible.
  2. Guard render() entry point with if p.config.invisible { return nil }.
  3. Add unit tests in progressbar_test.go covering AddDetail both when visible and when configured with OptionSetVisibility(false) to ensure no bytes are written to the writer.

Fixes #236

@AdamMagued

Copy link
Copy Markdown
Author

Closing in favor of earlier community PR #237 to avoid duplicate review effort.

@AdamMagued AdamMagued closed this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AddDetail cause progressbar to render even when visible is false

1 participant