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

fix data source slug update in the form #204

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

shekharnwagh
Copy link
Contributor

@shekharnwagh shekharnwagh commented Nov 19, 2024

Issue

A bug was introduced in #195 where the slug field in the data source form wouldn't update properly under certain conditions. The bug occurred because the SlugInput component was comparing the sanitized slug with its local state instead of the form's state.

Bug Details

The component would:

  1. Compare sanitized slug with local unsanitized slug
  2. Only update in form state if they were different
  3. Ignore whether the value differed from form state

This caused the form state to retain old/empty values even when the user had entered valid input.

Steps to Reproduce

  1. Open "Add Data Source" form
  2. Enter a slug that remains unchanged after sanitization (e.g., "my-data-source")
  3. Submit form
  4. Form fails because slug remains empty in form state

Fix

Modified the comparison to check against the form's slug prop instead of local state, ensuring form state updates correctly regardless of sanitization results.

Testing

  1. Open "Add Data Source" form
  2. Enter various slugs:
    • Slugs needing sanitization (e.g., "My Data Source")
    • Slugs already sanitized (e.g., "my-data-source")
  3. Verify form state updates correctly
  4. Confirm successful form submission

When updating the new sanitized slug in form state it was compared with
the unsanitized version of it in the local state of SlugInput component.
This led to cases when the sanitized and unsanitized version being same,
the changed slug was not updated in form state leading to it not being
saved when 'Save' button on form was clicked. Comparing the local
sanitized version with slug in the form state fixes it.
@shekharnwagh shekharnwagh added the bug Something isn't working label Nov 19, 2024
@shekharnwagh shekharnwagh self-assigned this Nov 19, 2024
@shekharnwagh shekharnwagh changed the title fix data source slug input fix data source slug update in the form Nov 19, 2024
@maxschmeling maxschmeling merged commit c7917e9 into trunk Nov 19, 2024
10 checks passed
@maxschmeling maxschmeling deleted the fix/datasource-slug-input branch November 19, 2024 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants