Steps to replicate the issue (include links if applicable):
- Open popup.
- Select backend (leave state to "Off").
- Close popup.
- Reopen popup.
- Actual: Choice lost.
- Expected: Choice remembered.
Another way:
- Open popup.
- Turn state to "On", then select a backend.
- Close popup.
- Reopen popup.
- Actual: Choice lost.
- Expected: Choice remembered.
Another way:
- Open popup.
- Turn state to "On".
- Close popup.
- Reopen popup.
- Select a backend.
- Close popup.
- Reopen popup.
- Actual: Choice lost.
- Expected: Choice remembered.
The initial state has backend: null, which means the condition here skipped adding a 'change' event listener to the backend dropdown menu. So, when opening the popup, no matter what backend you select, it doesn't send a message to the background process, and thus it doesn't won't be used or remembered.
It is not completely broken, though, so long as you select your backend before toggling the main switch to "On", then that interaction will send a message, and that later message will contain the complete state, including the selected backend.
But, if you toggle it "On" first and then select your backend, it will actually use the first/default of k8s-mwdebug instead of your selected backend. Which isn't obvious since you don't generally re-open the popup after that. Except you'll see that when you open it again afterward the selection has seemingly gone back to the default, but in fact was never applied in the first place. Even before you "discover" the value going back to the default, it was still internally always the default.