Skip to content

Show Close instead of Apply in labels modal when there are no labels - #55

Open
hupponen wants to merge 1 commit into
masterfrom
labels-modal-buttons
Open

Show Close instead of Apply in labels modal when there are no labels#55
hupponen wants to merge 1 commit into
masterfrom
labels-modal-buttons

Conversation

@hupponen

Copy link
Copy Markdown
Contributor

Problem

The labels modal showed an Apply button even when the session had no labels at all. With nothing to check, Apply had nothing to apply — clicking it just closed the modal. The Cancel button next to it was equally pointless in that state.

Change

Added a canApply() helper — files selected and at least one label exists — and keyed the footer off it instead of hasSelection():

State Footer
Files selected, labels exist + New label Cancel Apply
No labels (or no files selected) + New label Close

So the no-labels case now behaves like the no-selection case: a single Close button.

hasSelection() is deliberately kept where it's still the right question — the header filename/count, the checkbox column, and addCreatedLabelRow() (which must pre-check a newly created label even though rows is still empty at that moment).

Also switched the Cancel and Close buttons in both label modals from btn-outline-secondary to btn-secondary, matching the ~25 other modal footers in the app. Apply/Save stay primary.

Notes

  • No behaviour change for the paths that already worked: confirm() was already a no-op with zero rows (applyRowsTo over an empty rows returns before unchanged, so datasetUpdates is empty and the modal just closes). No requests are fired by the new Close button.
  • Callers treat modal close and dismiss identically (datasetmodal.service.ts clears labelsModalRef in both handlers), so hiding Cancel can't leave the toggleLabelsModal guard stuck.
  • Not covered by tests — there are no specs for the session-view components.

Applying label checkboxes is meaningless when the session has no labels,
so the modal footer now falls back to a plain Close button in that case,
same as when no files are selected. The Cancel button is hidden too,
since it only makes sense next to Apply.

Also use btn-secondary for the Cancel and Close buttons in both label
modals, matching the other modal footers in the app.
@hupponen
hupponen requested a review from klemela August 25, 2026 10:56
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