React: Safari won't let me type on a text input

Created on 19 Feb 2019  路  5Comments  路  Source: facebook/react

I wrote a simple search box that works fine on Chrome and Firefox, but in Safari is another story. It let me type a single character and won't update any more.

2019-02-19 11 25 05

Here is the code

function Header({ history }) {
  const [q, setQ] = useState("");

  const onSubmit = e => {
    e.preventDefault();
    history.push({
      pathname: "/buscar",
      search: `q=${encodeURIComponent(q.trim())}`,
    });
  };

  return (
    <header className={styles.Header}>
      <div className={styles.Container}>
        <form className={styles.Form} onSubmit={onSubmit}>
          <input
            autoCapitalize="off"
            autoComplete="off"
            autoCorrect="off"
            autoFocus
            className={styles.Input}
            onChange={e => setQ(e.target.value)}
            placeholder="Buscar por nombre, dni o cuit"
            spellCheck="false"
            type="search"
            value={q}
          />
          <button type="submit" className={styles.Submit}>
            Buscar
          </button>
        </form>
      </div>
    </header>
  );
}

Am I missing something? Is this a known bug?

Needs More Information

Most helpful comment

I believe this is not an React issue, it's the issue with -webkit-user-select: inherit; (CSS) getting applied to Safari.

All 5 comments

A reproducing case please.

@gaearon Sorry, here is a prototype: https://cuit.app

Can you make a standalone example with inspectable code please? Like CodeSandbox.

I believe this is not an React issue, it's the issue with -webkit-user-select: inherit; (CSS) getting applied to Safari.

@gaearon Yes I can, but it won't be necessary. @TienDo1011 you are right, user-select was the problem. Thank you and sorry for this dummy issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

varghesep picture varghesep  路  3Comments

UnbearableBear picture UnbearableBear  路  3Comments

huxiaoqi567 picture huxiaoqi567  路  3Comments

krave1986 picture krave1986  路  3Comments

jvorcak picture jvorcak  路  3Comments