Act on the selected row, not the one the table moved to
In Users, pressing k on a user opened API keys for the user above it. The dashboard hands every key to the section's table before the section's own handler reads the cursor, and bubbles' table claims several letters for navigation: k is up, d half a page down, f a page down. A letter that is also an action therefore moved the cursor first, and the action landed on the row it had moved to. With your own user first in the list, k looked like it only ever showed your own keys. The same collision hit two destructive keys: - d in Users asked to delete a user half a page below the selected one. The confirmation names the user, and that was the only thing standing between a keypress and deleting the wrong person. - d in Schedule targeted a different day's assignment the same way. f in Incidents and Alerts cycled the filter and paged the cursor down too, which was harmless but wrong. Each table now gives up exactly the letters its section acts on, through tableKeyMap. The arrow keys and every other default binding are untouched. The cost is that k no longer moves up in Users, where it means API keys, as the README has always said. The up arrow still works, and the README now says to use it there. users_test.go reproduces all four. With tableKeyMap reverted to the defaults, each of them fails exactly as reported.
This commit is contained in:
Reference in New Issue
Block a user