Skip to content

Inconsistent jumping inside flex item #182

Open
@SpasiboKojima

Description

@SpasiboKojima

Basically I'm trying to add an error message under input, input is inside div which gets parent ref from auto-animate, and the div is inside flex container with 2 other elements. Both the message and the input are jumping inconsistently during animation.

Removing flex property from container solves it, as well as removing 2 other flex items.

I saw the tips about flexbox layouts, but the box expands nicely, so not sure if this is the case? If it is, how can I specify explicitly height, if I really need the box to grow in size?

input.mp4

Basically my component, Tailwind + DaisyUI

const Register = () => {
  const [pass, setPass] = useState('');
  const [isError, setIsError] = useState(false);
  const [parent] = useAutoAnimate({ duration: 1000 });

  return (
    <div className="flex min-h-screen flex-col items-center justify-between bg-slate-500 p-24">
      <div className="text-lg/loose text-primary">WHERE</div>
      <h1 className="text-5xl/relaxed text-blue-dark-700">Get Started</h1>
      <div className="rounded-2xl bg-white p-8">
        <div className="form-control w-[300px] gap-5 pt-8">
          <div ref={parent}>
            <input
              type="password"
              placeholder="Password"
              className={`input input-bordered w-full max-w-xs ${isError && 'input-error'}`}
              onChange={(e) => setPass(e.target.value)}
              value={pass}
            />
            {isError && <div className="text-error">Your password is not strong enough. Your password must be at least 10 characters</div>}
          </div>
          <button
            className="btn btn-primary w-full text-white"
            onClick={() => {
              if (pass.length < 10) {
                setIsError(true);
              } else {
                setIsError(false);
              }
            }}
          >
            Register
          </button>
        </div>
      </div>
    </div>
  );
};

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