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

Radio button reset when switching asset models #15007

Open
2 tasks done
nicholasveronico opened this issue Jul 2, 2024 · 12 comments
Open
2 tasks done

Radio button reset when switching asset models #15007

nicholasveronico opened this issue Jul 2, 2024 · 12 comments
Assignees
Labels
✋ bug Confirmed bug

Comments

@nicholasveronico
Copy link

nicholasveronico commented Jul 2, 2024

Debug mode

Describe the bug

When changing an asset's asset model, the radio button selection is reset. I am unsure if this is intentional; however, the values of other custom fields, such as the listbox, are not reset when changing an asset model. The following video shows the radio button selection being reset:

https://imgur.com/a/HB06QMj

Please note that the Billing custom field shown in the video is present in both asset models.

Thank you so much in advance!

Reproduction steps

  1. Create a custom radiobutton field and add it to two fieldsets used in two different asset models.
  2. Create an asset with one asset model and with the radio button field checked to one of the options and save the asset.
  3. Edit the same asset but change the asset model to a secondary asset model.

The radio button will reset the selection.

Expected behavior

It is expected to keep the selected value of the radio button the same as long as the same field is present in both fieldsets associated with any two different asset models.

Screenshots

https://imgur.com/a/HB06QMj

Snipe-IT Version

v7.0.7 build 14172

Operating System

Ubuntu 20.04

Web Server

Nginx

PHP Version

8.3.8

Operating System

Mac

Browser

Safari, Microsoft Edge

Version

Edge: 126.0.2592.81, Safari: 17.5

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

Browser Console Error (happens before changing the asset model, though):
edit:925 
 Uncaught 
TypeError: $ is not a function
    at edit:925:5
(anonymous)	@	edit:925


When changing asset models, the following is logged in Snipe-IT's debug:

[17:34:02] LOG.warning: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /config/storage/framework/views/d2583f90a56f99c2c0bc40b509d051ff.php on line 35

I can confirm this issue also occurs on the demo instance. 

PHP Output:
https://hastebin.com/share/zevuhekayu.css

Additional context

This issue occurs on a fresh install and upgrade, on a manual install and Docker install. Data has not been manually edited in the DB.

Copy link

welcome bot commented Jul 2, 2024

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@snipe snipe added the ✋ bug Confirmed bug label Jul 2, 2024
@snipe
Copy link
Owner

snipe commented Jul 2, 2024

@marcusmoore can you peep this, or coordinate with @spencerrlongg or @Godmartinz to see who is best suited (and has the bandwidth) to dig deeper? I think this is related to the SC I created last week, so we might able to kill a few birds with one stone.

@marcusmoore
Copy link
Collaborator

I'll check it out 👍🏾

@nicholasveronico
Copy link
Author

I'll check it out 👍🏾

Hi Marcus!

I just wanted to check in and see if there's any updates on this issue.

Thanks!!

@marcusmoore
Copy link
Collaborator

Still on my radar. I have done some work on this but it's not ready to be merged yet.

@nicholasveronico
Copy link
Author

Still on my radar. I have done some work on this but it's not ready to be merged yet.

Awesome, thanks for the update!

@nicholasveronico
Copy link
Author

Hi @marcusmoore!

Is there a PR or branch I can follow for this issue? I noticed a similar issue was fixed in #15486; however, this issue is still present.

Thank you so much!

@marcusmoore
Copy link
Collaborator

This got lost in the mix. I'll check this out this week.

@marcusmoore
Copy link
Collaborator

A couple notes: the behavior is different for when you're creating vs updating an asset.

Using a text field as an example: when you're creating an asset, selecting a asset model that has default values for a custom field will always set the value to the default, even if the user entered something different.

Continuing to use a text field as an example: when you're updating an asset, changing the value for an input, then switching to an asset model that has a default value for that input results in the user entered input 'sticking'.

In either case (creating vs updating), checkboxes and radio inputs are updated to the field's default value when the asset model is switched.


It seems like inputs that are "dirty", meaning a user has updated the value, should stick with what the user entered even if there is a default value for the field.

A question I have is, if a user hasn't entered input for a field, should the default value be applied? Does that change when creating vs updating 🤔

Any input @nicholasveronico?

@nicholasveronico
Copy link
Author

A couple notes: the behavior is different for when you're creating vs updating an asset.

Using a text field as an example: when you're creating an asset, selecting a asset model that has default values for a custom field will always set the value to the default, even if the user entered something different.

Continuing to use a text field as an example: when you're updating an asset, changing the value for an input, then switching to an asset model that has a default value for that input results in the user entered input 'sticking'.

In either case (creating vs updating), checkboxes and radio inputs are updated to the field's default value when the asset model is switched.

It seems like inputs that are "dirty", meaning a user has updated the value, should stick with what the user entered even if there is a default value for the field.

A question I have is, if a user hasn't entered input for a field, should the default value be applied? Does that change when creating vs updating 🤔

Any input @nicholasveronico?

I think if the field has no value set initially, the default value being present is the most sound option. For radio and checkboxes, I do think the user's input should stick.

For creating vs. updating, in my opinion (assuming you mean switching asset models when creating an asset vs. editing), the behaviour should be the same (user input has higher precedence over default values). But, if there is no user-inputted value for that custom field, the default value can be applied.

@nicholasveronico
Copy link
Author

Hi @marcusmoore! I was just wondering if there's any update on this issue? Thanks!

@snipe
Copy link
Owner

snipe commented Jan 6, 2025

@marcusmoore Welcome back - can you take a look at this when you get a moment?

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

No branches or pull requests

3 participants