Skip to content

onKeyDownCapture and onKeyDown overwrite each other #2739

@mischnic

Description

@mischnic

Reproduction

https://codesandbox.io/s/preact-on-capture-overwrite-e8dfk?file=/src/index.js:0-548

//import React from "react";
//import ReactDOM from "react-dom";

import React from "preact/compat";
import ReactDOM from "preact/compat";

function App() {
  return (
    <div
      onKeyDown={() => console.log("div noncapture")}
      onKeyDownCapture={() => console.log("div capture")}
    >
      <input
        onKeyDown={() => console.log("input noncapture")}
        onKeyDownCapture={() => console.log("input capture")}
      />
    </div>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

Steps to reproduce

Open codesandbox and type into the input field

Expected Behavior

Console:

div capture 
input capture 
input noncapture 
div noncapture 

This is how React behaves

Actual Behavior

div capture 
input capture 
input capture 
div capture 

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