Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubmissionList: modelValue of Multiselect can change while options are shown #664

Open
matthew-white opened this issue Nov 29, 2022 · 1 comment
Labels

Comments

@matthew-white
Copy link
Member

matthew-white commented Nov 29, 2022

The Multiselect component assumes that its modelValue prop will not change while the list of options (the dropdown) is shown. That seems like it should be a fair assumption, yet it is possible for it to be violated for SubmissionFiltersSubmitter and SubmissionFiltersReviewState, two Multiselect components in SubmissionList. If the user clicks either Multiselect, then changes the corresponding query parameter (submitter or reviewState) while the options are shown — manually, by pressing the back button, etc. — then that will violate the assumption. The resulting state isn't well-defined, but it does look like things go wrong:

  • Navigate to the Submissions page.
  • Use the review state filter to filter for approved submissions. That will change the query string to ?reviewState='approved'.
  • Click the review state filter again. While its options are shown, change the query string to ?reviewState='approved'&reviewState='rejected'.
  • Observe that nothing has changed in the list of options: Rejected is still not selected.
  • That alone might be reasonable behavior. But now do select Rejected and close the list of options.
  • SubmissionFiltersReviewState emits an update:modelValue event though its modelValue hasn't actually changed. You would think that that would cause the router to navigate to the same location, resulting in a router error.
  • However, what happens is more interesting: only Rejected ends up being selected, not Approved. I think that's because selected is cleared as soon as the modelValue changes.

I think there are two main ways that we could address this issue. (I'm thinking that this isn't something that we need to do for v2022.3.)

First, we could prevent navigation while the list of options of either Multiselect is shown. I don't think it makes sense for Multiselect itself to implement that logic, but if we had Multiselect emit shown and hidden events, then SubmissionFiltersSubmitter and SubmissionFiltersReviewState could watch for those and prevent navigation if there has been a shown event without a hidden event.

Alternatively, we could change Multiselect so that it allows modelValue to change while the list of options is shown. We would have to decide what the desired behavior is in that case (should the selections update immediately to match the new modelValue? what if the user has already made changes?). We might end up needing to patch selected and/or changes as soon as modelValue changes.

@matthew-white
Copy link
Member Author

This is also an issue for EntityFiltersConflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant