Skip to content

fix(ui): re-enable Add button when hetero-list item is deleted#26937

Open
amarkdotdev wants to merge 1 commit into
jenkinsci:masterfrom
amarkdotdev:fix/hetero-list-add-button-state
Open

fix(ui): re-enable Add button when hetero-list item is deleted#26937
amarkdotdev wants to merge 1 commit into
jenkinsci:masterfrom
amarkdotdev:fix/hetero-list-add-button-state

Conversation

@amarkdotdev

@amarkdotdev amarkdotdev commented Jun 16, 2026

Copy link
Copy Markdown
Member

Fixes #26737

When all items are added to a one-each hetero-list (e.g. post-build actions in a Freestyle job), the Add button correctly disables. But when an item is removed, the button stays disabled until clicked. Regression from #10186.

Root cause: toggleButtonState() counts .repeated-chunk elements to determine if the list is full. Deleted elements get the fade-out class and are only DOM-removed after the CSS transition ends. The MutationObserver (watching childList) fires too late.

Fix:

  1. Exclude .fade-out elements from the count — they are logically deleted.
  2. Observe attributes (class changes) in addition to childList, so the button re-enables immediately when fade-out is applied.

Testing done

Reproduced the bug on Jenkins 2.536+ by adding all post-build actions in a Freestyle job until the Add button disabled, then deleting one. Before the fix, button stays disabled. After the fix, button re-enables immediately on deletion.

Screenshots (UI changes only)

Not included — the visual behavior is that the Add button transitions from disabled to enabled state when a list item is deleted, matching the pre-2.536 behavior.

@krisstern

Copy link
Copy Markdown
Member

Please restore the default pull request template for submitting pull requests

@amarkdotdev

Copy link
Copy Markdown
Member Author

/label regression-fix

@comment-ops-bot comment-ops-bot Bot added the regression-fix Pull request that fixes a regression in one of the previous Jenkins releases label Jun 16, 2026
When an item is deleted from a one-each hetero-list, the Add button
stays disabled until manually clicked. This regression was introduced
in jenkinsci#10186.

Root cause: toggleButtonState counts elements with class
repeated-chunk, but deleted elements get the fade-out class and are
only removed from the DOM after the CSS transition ends. The
MutationObserver fires on childList changes (actual removal), which
happens too late — by the time the animation ends the user has already
seen a disabled button they cannot use.

Fix:
- Exclude elements with the fade-out class from the selected count in
  toggleButtonState, since they are visually and logically deleted.
- Observe attribute changes (class) in addition to childList, so
  toggleButtonState runs immediately when fade-out is applied rather
  than waiting for the element to be physically removed.

Fixes jenkinsci#26737

Signed-off-by: Aaron <aaroniofjm@gmail.com>
@amarkdotdev amarkdotdev force-pushed the fix/hetero-list-add-button-state branch from e80cdc8 to a904392 Compare June 16, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

regression-fix Pull request that fixes a regression in one of the previous Jenkins releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleting an element from a "full" hetero(?) list does not re-enable the "Add" button

2 participants