Skip to content

Simplify conditional rendering logic in scheduledMaintenanceComponent#38

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-confusing-conditional-rendering
Draft

Simplify conditional rendering logic in scheduledMaintenanceComponent#38
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-confusing-conditional-rendering

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 17, 2026

Nested if:true/if:false blocks across the header and footer made the three distinct modal states (dismissible, app-lock, full-lock) hard to reason about. The isFullLock inner guard inside if:true={isDismissible} blocks was always vacuously true since isDismissible = !isFullLock && (...) by definition.

Changes

scheduledMaintenanceComponent.js

  • Added get showNavigateButton() getter as the single source of truth for the app-lock state:
    get showNavigateButton() {
        return !this.isDismissible && !this.isFullLock;
    }

scheduledMaintenanceComponent.html

  • Removed redundant <template if:false={isFullLock}> wrapper nested inside if:true={isDismissible} (close button in header, dismiss button in footer)
  • Replaced double-negative if:false={isDismissible} + if:false={isFullLock} footer guard with if:true={showNavigateButton}

The three resulting states are now each controlled by a single, clearly-named condition:

State Condition Close/Dismiss Navigate
Normal isDismissible
App lock showNavigateButton
Full system lock neither

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Three new Jest tests cover all footer-button rendering scenarios, each mounting the component with mocked Apex data that produces the target state:

  • Dismissible in-progress maintenance → Dismiss shown, Navigate hidden
  • Non-system non-dismissible maintenance (app lock) → Navigate shown, Dismiss hidden
  • System non-dismissible maintenance (full lock) → both buttons hidden

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Screenshots (if applicable):

No visual changes — the rendered output is identical; only the template logic was simplified.

Additional Notes

The five pre-existing ESLint errors (no-dupe-class-members, @lwc/lwc/no-api-reassignments, @lwc/lwc/no-async-operation, no-case-declarations) are unrelated to this change and were present before this PR.

Original prompt

This section details on the original issue you should resolve

<issue_title>Confusing conditional rendering logic</issue_title>
<issue_description>Nested if:true / if:false blocks and multiple flags (isDismissible, isFullLock, maint.Dismissible__c) make behavior hard to reason about.

Proposed Fix

  • Simplify conditions
  • Define a single source of truth for dismissibility and lock state

File: scheduledMaintenanceComponent.html</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…tton getter

- Remove redundant `if:false={isFullLock}` nested inside `if:true={isDismissible}`
  blocks (close button in header and dismiss button in footer), since
  `isDismissible = !isFullLock && (...)` already guarantees isFullLock=false when
  isDismissible=true.
- Replace double-negative `if:false={isDismissible}` + `if:false={isFullLock}` in
  the footer with a single `if:true={showNavigateButton}` using a new named getter.
- Add `get showNavigateButton()` getter (!isDismissible && !isFullLock) as the single
  source of truth for the app-lock navigate state.
- Add focused Jest tests covering all three footer-button rendering scenarios.

Co-authored-by: ethandunzer <180557240+ethandunzer@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix confusing conditional rendering logic Simplify conditional rendering logic in scheduledMaintenanceComponent Mar 17, 2026
Copilot AI requested a review from ethandunzer March 17, 2026 19:50
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.

Confusing conditional rendering logic

2 participants