Skip to content

Task List Widget: Edit input not prefilled & focused #222

@pathseek3r

Description

@pathseek3r

Description:
When clicking the Edit button for a task, the input field that appears is empty and not focused. Users have to retype the task label from scratch.

Steps to Reproduce:

  1. Click the Edit button for a task with an existing label.
Image
  1. Observe that the input field is empty and focus is not applied.
Image

Expected Behavior:
The input field should be prefilled with the current task label and focused.

Root Cause (Code Snippet):

const editTask = () => {
    setIsEditing((prevValue) => {
      inputRef.current?.focus();
      if (inputRef.current) {
        inputRef.current.value = titleRef.current;
      }
      return !prevValue;
    });
  };

The issue occurs because the DOM element (inputRef.current) may not exist yet when setIsEditing toggles the state, causing focus and value assignment to fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions