Skip to content

Item entry scrolls down even when adding a duplicate item #8

@Spacerat

Description

@Spacerat
  const onSubmit: React.FormEventHandler<HTMLFormElement> = React.useCallback(
    (e) => {
      e.preventDefault();
      if (value.length > 0) {
        onAddItems([value]);
        setValue("");
        textRef.current?.focus();
        // HACK: keep the bottom of the list in view.
        // scrollIntoView doesn't seem to work well for this on mobile.
        // Is there a better way?
        if (keepInView) setTimeout(() => window.scrollBy(0, 52), 1);
      }
    },
    [onAddItems, value, keepInView]
  );

onAddItems might not add anything if the item already exists, but we still scroll down.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions