Skip to content

Conversation

@hamed-zeidabadi
Copy link

Description

This PR fixes a critical bug in the Modal component where isHidden and isVisible were being called as properties instead of methods.

Bug Details

In the show() and hide() methods, the code was checking:

  • if (this.isHidden) instead of if (this.isHidden())
  • if (this.isVisible) instead of if (this.isVisible())

Since these are methods, calling them without parentheses returns the function reference (which is always truthy), causing the conditions to always evaluate to true. This means:

  • The show() method would always execute its logic, even if the modal was already visible
  • The hide() method would always execute its logic, even if the modal was already hidden

Changes

  • Line 213: this.isHiddenthis.isHidden()
  • Line 230: this.isVisiblethis.isVisible()

Impact

This bug could cause:

  • Multiple event listeners being attached
  • Incorrect state management
  • Potential memory leaks
  • Unexpected behavior when calling show/hide multiple times

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change
  • Documentation update

Fix bug where isHidden and isVisible were called as properties instead of methods.
This was causing the conditions to always evaluate to truthy (function reference)
instead of the actual boolean return value.

Changes:
- this.isHidden -> this.isHidden()
- this.isVisible -> this.isVisible()
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.

1 participant