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(frontend): Newly typed text in Input fields vanishes on scroll #8657

Conversation

majdyz
Copy link
Contributor

@majdyz majdyz commented Nov 15, 2024

This fixes #8625

Due to the input values are globally managed and asynchronous, the onBlur event was used instead of onChange to avoid the jumping caret problem.

However, this causes issues when there could be some re-render events that still keep the input box focused, making the onBlur not triggered, but the input was reset. One such scenario is the scrolling (zoom-in & zoom-out of the node editor).

Changes 🏗️

Introduce & use LocalValuedInput. Instead of using onBlur as a trigger, the component maintains its local state value to be displayed on the input box, but also calls the onChange update on the globally managed value state, while syncing its value from the outside.

Checklist 📋

For code changes:

  • I have clearly listed my changes in the PR description
  • I have made a test plan
  • I have tested my changes according to the test plan:
    • ...
Example test plan
  • Create from scratch and execute an agent with at least 3 blocks
  • Import an agent from file upload, and confirm it executes correctly
  • Upload agent to marketplace
  • Import an agent from marketplace and confirm it executes correctly
  • Edit an agent from monitor, and confirm it executes correctly

For configuration changes:

  • .env.example is updated or already compatible with my changes
  • docker-compose.yml is updated or already compatible with my changes
  • I have included a list of my configuration changes in the PR description (under Changes)
Examples of configuration changes
  • Changing ports
  • Adding new services that need to communicate with each other
  • Secrets or environment variable changes
  • New or infrastructure changes such as databases

@majdyz majdyz requested a review from a team as a code owner November 15, 2024 07:39
@github-actions github-actions bot added platform/frontend AutoGPT Platform - Front end platform/backend AutoGPT Platform - Back end size/m labels Nov 15, 2024
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

8625 - Fully compliant

Compliant requirements:

  • Fix bug where newly typed text in input fields vanishes when scrolling
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

State Management
The useEffect hook in LocalValuedInput component doesn't have inputValue in its dependency array. While commented as intentional, this pattern could potentially lead to stale state issues. Verify the component behaves correctly in all edge cases.

Type Safety
The value prop passed to LocalValuedInput in NodeNumberInput component might need type checking or conversion before being set as the input value to ensure type consistency

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for auto-gpt-docs canceled.

Name Link
🔨 Latest commit bddc5a7
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/6736fd3e3e98c500083bdc26

@majdyz majdyz enabled auto-merge (squash) November 15, 2024 07:43
@majdyz majdyz merged commit f27f596 into dev Nov 15, 2024
15 checks passed
@majdyz majdyz deleted the zamilmajdy/open-2030-newly-typed-text-in-input-fields-vanishes-on-scroll branch November 15, 2024 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform/backend AutoGPT Platform - Back end platform/frontend AutoGPT Platform - Front end Review effort [1-5]: 2 size/m
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants