Skip to content

Do not raise in gl_redirect_listbox_tag if selected item is not found

Mark Florian requested to merge 354424-listbox-handle-invalid-selected into master

What does this MR do and why?

Do not raise if selected item is not found in gl_redirect_listbox_tag

As noticed in !80681 (comment 862019211) and !81370 (comment 854661919), the result of raising if the selected item cannot be found is a 500 error. Considering this can be triggered by user behaviour (i.e., changing the URL) the only sensible way to handle this is to select the first item, as was already the case for selected: nil.

Addresses #354424 (closed).

Screenshots or screen recordings

Before After
before_fix after_listbox_fix

How to set up and validate locally

  1. Visit /admin/users?sort=foobar
  2. Observe that the Name is the selected sort option, instead of an error page

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #354424 (closed)

Edited by Mark Florian

Merge request reports