fix(display): correct module trigger logic and ensure header visibility#45
fix(display): correct module trigger logic and ensure header visibility#45dfl-aeb wants to merge 1 commit intowonderslug:mainfrom
Conversation
This commit addresses an issue where module headers were displayed even when the module itself was hidden by the `moduleTriggerTemplate`. It also corrects a typo in the `useModuleTrigger` configuration option. Additionally, backward compatibility for the misspelled `useModuleTigger` option has been introduced to prevent breaking changes for existing configurations.
There was a problem hiding this comment.
Pull Request Overview
This PR fixes display issues in the MMM-HomeAssistantDisplay module by correcting module trigger logic and ensuring proper header visibility control. The changes address overlapping headers when modules should be hidden and fix a configuration option typo.
- Corrected typo from
useModuleTiggertouseModuleTriggerwhile maintaining backward compatibility - Fixed header visibility logic to hide headers when modules are triggered to be hidden
- Updated trigger condition checks throughout the module to use corrected logic
| debuglogging: false, | ||
| useModuleTigger: false, | ||
| useModuleTrigger: false, // Corrected typo: useModuleTigger -> useModuleTrigger | ||
| useModuleTigger: false, // For backwards compatibility |
There was a problem hiding this comment.
The comment maintains the intentional misspelling 'Tigger' for backward compatibility, but it should clarify that this is a deprecated option. Consider updating the comment to: '// For backwards compatibility - deprecated, use useModuleTrigger instead'
| useModuleTigger: false, // For backwards compatibility | |
| useModuleTigger: false, // For backwards compatibility - deprecated, use useModuleTrigger instead |
| // If the module is configured to use a trigger to control its visibility, | ||
| // and the trigger currently indicates the module should be hidden, | ||
| // then do not return a title, so no header is rendered. | ||
| if ((this.config.useModuleTrigger || this.config.useModuleTigger) && !this.displayModule) { |
There was a problem hiding this comment.
The condition checks !this.displayModule but displayModule is not defined or initialized in the visible code. This could result in the header always being hidden if displayModule is undefined. Ensure displayModule is properly initialized and updated based on the module trigger logic.
Fix: Module Trigger Logic and Header Visibility
Problem:
moduleTriggerTemplate. This led to overlapping headers in the user interface.useModuleTiggerinstead ofuseModuleTrigger).Solution:
This PR addresses the issues mentioned above with the following changes:
getHeaderfunction inMMM-HomeAssistantDisplay.jshas been adjusted to returnnull(and thus render no header) when the module is hidden viauseModuleTrigger(oruseModuleTigger).useModuleTiggerhas been corrected touseModuleTriggerthroughout the module file (MMM-HomeAssistantDisplay.js).useModuleTiggeroption has been implemented. The module now checks for both spellings (useModuleTrigger || useModuleTigger).Impact:
useModuleTiggertypo will continue to work without requiring modification.