You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Opening the Filter Menu can cause a refresh when the backing value changes from a string to an integer, even if the value is effectively the same (e.g. 2 vs "2").
Detailed steps to reproduce the issue on a fresh Nova installation:
Follow these steps:
Create a resource
Add a filterable select field
Have the select field's option values be integers
In the UI, filter to any option
Refresh the page (this forces the filter values to source from the URL string)
Open the filter menu
The resource table will refresh just by opening the menu, despite not having selected anything yet
It took me awhile to figure this one out, but the root cause was the filter value changing from a string to an integer (e.g. "2" to 2). When a value is initially selected, the value ends up being a string. However, when the value is initialized from a string, the Filter/SelectField component finds the option matching the string-based value, and assigns option.value to this.value, where option.value was actually an integer.
I was able to hack in a fix by modifying the source code for Filter/SelectField's watch:selectedOption function, and changing this.value = option.value to this.value = String(option.value). There may be edge cases that need to be explored, but that solution definitely solved my problem.
The text was updated successfully, but these errors were encountered:
Please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example)
I've created a repository for you, and I've linked a pull request (to my own repository) that shows you the files I added on top of the default Nova installation.
Description:
Opening the Filter Menu can cause a refresh when the backing value changes from a string to an integer, even if the value is effectively the same (e.g.
2
vs"2"
).Detailed steps to reproduce the issue on a fresh Nova installation:
Follow these steps:
Repository:
https://github.com/tylernathanreed/nova-issues/pull/1/files
Video:
Nova.6424.mp4
Root Cause
It took me awhile to figure this one out, but the root cause was the filter value changing from a string to an integer (e.g.
"2"
to2
). When a value is initially selected, the value ends up being a string. However, when the value is initialized from a string, theFilter/SelectField
component finds the option matching the string-based value, and assignsoption.value
tothis.value
, whereoption.value
was actually an integer.I was able to hack in a fix by modifying the source code for
Filter/SelectField
'swatch:selectedOption
function, and changingthis.value = option.value
tothis.value = String(option.value)
. There may be edge cases that need to be explored, but that solution definitely solved my problem.The text was updated successfully, but these errors were encountered: