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

Select Field does not return a value on v4.32.12 (strict equality issue) #6211

Closed
LTKort opened this issue Feb 15, 2024 · 6 comments
Closed
Labels
bug Verified bug by the Nova team

Comments

@LTKort
Copy link

LTKort commented Feb 15, 2024

  • Laravel Version: 10.44.0
  • Nova Version: 4.32.12
  • PHP Version: 8.3.0
  • Database Driver & Version: MySQL
  • Reproduction Repository: https://github.com/laravel/nova

Description:

Since the update for v4.32.12, a Select field with options that uses an Integer as key is not returned as a valid selectedOption.
In the SelectField.vue there are some changes made with comparisons:

let selectedOption = find(
    this.currentField.options,
-     v => v.value == this.currentField.value
+     v => v.value === this.currentField.value
)

The key type (this.currentField.value) differs from the selected options key type (v.value), which causes an empty selectedOption.
It looks like the selected value is compared as text vs number, while PHP sets the value as an integer.
The issue does not appear in v4.32.11

Detailed steps to reproduce the issue on a fresh Nova installation:

Add a Select field to an Action, fill the with options $options = User::limit(5)->pluck("name", "id"); (Array or Collection)
Run the action, the field value for the handle with be empty.

@crynobone crynobone added the bug Verified bug by the Nova team label Feb 15, 2024
@filipposallemi
Copy link

@taylorotwell @davidhemphill shame

@LTKort
Copy link
Author

LTKort commented Feb 16, 2024

@crynobone If I add a function to map the option values to a string, the Select field & strict equality seems to be working.

Example:

mappedOptions() {
  let mappedOptions = this.currentField.options.map(option => {
    return { label: option.label, value: `${option.value}` }
  })
  return Object.assign(this.currentField.options, mappedOptions)
},

Before: {label: 'Lars', value: 1}
After: {label: 'Lars', value: '1'}

@mddickens
Copy link

@taylorotwell @davidhemphill shame

Yep, blew up production this morning. Does anyone test these changes?

@filipposallemi
Copy link

The reality is that they are not using Nova at all otherwise they would have spot those issues immediately

@VenoM9078
Copy link

been 2 days, any update on this?

Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Verified bug by the Nova team
Projects
None yet
Development

No branches or pull requests

5 participants