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

Changes to new dependent resource from Query Combo Box not initially saved #6058

Open
melton-jason opened this issue Jan 10, 2025 · 0 comments
Labels
1 - Bug Incorrect behavior of the product 2 - Forms Issues that are related to the form system

Comments

@melton-jason
Copy link
Contributor

Describe the bug
If a dependent relationship is displayed as a Query Combo Box and the "create new resource" (plus) button is clicked, all changes to the dependent resource are lost when the save button is pressed.

issue_demo.mov

This has been an Issue since at least v7.9.6.2.

To Reproduce
Steps to reproduce the behavior:

  1. On a form definition for any table, add a to-one dependent relationship as a query combo box
  2. Go to the Data Entry form for the table
  3. Click on the green plus button to open up the new resource dialog
  4. Enter data into any field for the dependent relationship and Save the dependent resource
  5. (optional) Click on the pencil icon to open up the dependent form: see that all data has been lost
  6. Save the parent record
  7. See an "empty" dependent resource has been saved
  • Once the dependent resource has been explicitly saved to the parent, any further changes are not lost

Please fill out the following information manually:

  • OS: macOS Sonoma (14.3)
  • Browser: Chrome 131.0.6778.264 (arm64)
  • Specify 7 Version: production - 3790744

Cause of Issue

When the save button is pressed on the dependent resource to save it to the parent, it triggers a set call to set the dependent resource onto the parent

onSaved={(): void => {
resource?.set(field.name, state.resource as never);
setState({ type: 'MainState' });
}}

The set call is fed through the frontend resource API, which eventually triggers a change event

this.trigger(`change:${fieldName}`, this);

One listener of the change event is useResourceValue, which wants to parse and format the newly changed dependent resource. The problem lies in that resource.get still returns the previous value of null or undefined, as the change in the resource api has not yet set the dependent resource on the parent resource.

? resourceOn(
resource,
`change:${field.name}`,
(): void => updateValue(resource.get(field.name) as T),
true
)

resource.set(field.name, formattedValue as never, {

@melton-jason melton-jason added 1 - Bug Incorrect behavior of the product 2 - Forms Issues that are related to the form system labels Jan 10, 2025
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Front-End Backlog Jan 10, 2025
@melton-jason melton-jason changed the title Changes to new dependent resources from Query Combo Box not initially saved Changes to new dependent resource from Query Combo Box not initially saved Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 - Bug Incorrect behavior of the product 2 - Forms Issues that are related to the form system
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant