Skip to content

NSPopUpButtonCell: keep the correct selection when removing an item#487

Open
DTW-Thalion wants to merge 1 commit into
gnustep:masterfrom
DTW-Thalion:fix/nspopupbuttoncell-remove-reselect
Open

NSPopUpButtonCell: keep the correct selection when removing an item#487
DTW-Thalion wants to merge 1 commit into
gnustep:masterfrom
DTW-Thalion:fix/nspopupbuttoncell-remove-reselect

Conversation

@DTW-Thalion

@DTW-Thalion DTW-Thalion commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

-[NSPopUpButtonCell removeItemAtIndex:] mishandled the selection in two
ways:

  1. When the selected item was removed, the popup was left with no
    selection. OS X selects the first remaining item (and clears the
    selection only when the list becomes empty).

  2. When a different item before the selection was removed, the removal
    posts a notification that re-syncs the selection from the menu view's
    highlighted index — which does not track the removed item — so the
    selection slid to a different item. OS X keeps the selection on the same
    item (its index just shifts down).

Select the first item when the selected item is removed, and otherwise
re-select the item that was selected. Verified on a macOS runner across
all four cases (remove selected middle/last, remove an earlier item,
remove the only item).

Adds a test for the selection after removing an item.

@DTW-Thalion DTW-Thalion requested a review from fredkiefer as a code owner July 12, 2026 15:37
@DTW-Thalion DTW-Thalion force-pushed the fix/nspopupbuttoncell-remove-reselect branch from b1582d1 to cc6426f Compare July 12, 2026 15:51
@DTW-Thalion DTW-Thalion changed the title NSPopUpButtonCell: selecting after removing the selected item NSPopUpButtonCell: keep the correct selection when removing an item Jul 12, 2026
@DTW-Thalion DTW-Thalion force-pushed the fix/nspopupbuttoncell-remove-reselect branch 3 times, most recently from b7108e5 to b413cac Compare July 12, 2026 20:41
removeItemAtIndex: mishandled the selection in two ways.  When the
selected item was removed the popup was left with no selection; OS X
selects the first remaining item.  When a different item before the
selection was removed, the removal notification re-synced the selection
from the menu view's highlighted index (which does not track the removed
item), sliding the selection to another item; OS X keeps it on the same
item.  Select the first item when the selected item is removed, and
otherwise re-select the item that was selected.
@DTW-Thalion DTW-Thalion force-pushed the fix/nspopupbuttoncell-remove-reselect branch from b413cac to 00305e2 Compare July 12, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant