If the current value is not in the calculated options,
`text_if_current_value_not_in_options` can be provided to
the widget to show custom text in that case.
Used by stream / user announcement settings if user doesn't
have access to information about the currently selected stream.
It is possible that the current value of a dropdown widget is
valid but not present in options since the current user doesn't
have access it. So, we show [disabled] as value in that case.
This can be reproduced by setting a private stream for
notifications in org settings and then opening org settings
as a user which doesn't have access to the private stream.
This is a prep commit for moving towards typescript migration of this module.
We should make `get_item` required on `list_widget` because its intended to be
used with a set of keys and then hydrate the keys lazily. Also this will help
us to avoid writing messy if-conditions while filtering and sorting and make
our life much easier when we migrate to TypeScript.
I added a `default_get_item` function which is just n identity function and
also refactored some code to make use of default get item.
I didn't want to use JS for it since calculating height based on
item height before rendering the dropdown is expensive and after
rendering the dropdown will cause it jump.
After `ArrowDown` on the last visible, don't jump the next item
into the center of the view, instead align the bottom of the item,
to the bottom of the visible container.
This looks visually nicer, and I think is necessary to merge it for
now, but I'm doing this as a separate commit so it's easy to revert if
we change our mind.