Fix bug where unmounting and remounting the school autocomplete would… #19966
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
… cause it to show blank even when it had a value
This is a bit of a weird case, which was revealed in the teacher application. I'm not sure what
VirtualizedSelect
is doing under the hood with its caching logic, but it doesn't work in our case. Disabling the cache fixed it.Repro: when the school autocomplete was unmounted and then remounted, it would always show blank whether or not it had a value. This happened when we switch pages in the teacher application then come back to the school select page. However the first time it mounted (and therefore also after refreshing the page) it would load the options correctly and display the value. I added
console.log
s to determine that indeed, with the default caching, the underlyingVirtualizedSelect
was not calling ourloadOptions
callback when it remounted. With caching disabled now, it does.I'm not worried about perf since this isn't up for long and shouldn't be making too many duplicate calls, the backend sql query is optimized, and we will be debouncing the API call anyway.