gregwiechec / Alloy.HideTabs

Allow to hide tab and properties based on conditions
Apache License 2.0
4 stars 5 forks source link

Fix Iteration Over _formWidgets Properties #6

Open ariazanganehsudoroux opened 11 months ago

ariazanganehsudoroux commented 11 months ago

Overview:

This PR addresses the issue where our existing JavaScript logic was not iterating over all properties of the _formWidgets object as expected. The original implementation using a for...in loop missed non-enumerable properties and did not check for inherited properties. This led to incomplete processing of the _formWidgets object. Changes Made:

Replaced for...in Loop: The code now uses Object.getOwnPropertyNames() combined with .forEach(), ensuring all properties, including non-enumerable ones, are iterated over.
Robust Property Checks: Added checks for the existence of widget and widget.getParent() to prevent potential runtime errors when accessing properties.
Enhanced Visibility and Readability: Refactored the code for better readability and maintainability, making it easier for future modifications and understanding.

Impact:

Functionality: Ensures all properties of _formWidgets are correctly processed, leading to the expected behavior of our UI components.
Code Quality: Improves readability and robustness, reducing the likelihood of future bugs.
Maintainability: With clearer code structure, future updates and debugging are facilitated.

Testing:

Conducted comprehensive tests to ensure all properties are now being iterated over and processed correctly.
Verified the correct toggling of CSS classes in various scenarios to ensure UI behaves as expected.

How to Test:

Navigate to [specific module/page].
Perform [specific actions] to trigger the iteration over _formWidgets.
Observe that all relevant elements are now being shown/hidden as per their configuration in hiddenProperties.

Additional Notes:

This change is backward compatible with the existing usage of _formWidgets.
Reviewers are encouraged to check edge cases or any potential side effects.