reactpy icon indicating copy to clipboard operation
reactpy copied to clipboard

`event["target"]["checked"]` does not exist for checkbox inputs

Open Archmonger opened this issue 2 years ago • 5 comments
trafficstars

Current Situation

In ReactJS, event.target.checked would exist for checkboxes. However, this does not appear to be the case for ReactPy.

See the example in the docs for a scenario that should have worked.

Proposed Actions

Determine why our client side event handler isn't propagating the entire target context to the server.

Archmonger avatar Jun 19 '23 09:06 Archmonger

I think that can be fixed right here by adding checked: element.checked.

rmorshea avatar Jun 19 '23 17:06 rmorshea

@rmorshea Is there a chance there's a better way of doing this? I'm not seeing anywhere within preact's source code where they statically define event contents like this.

Archmonger avatar Jun 19 '23 21:06 Archmonger

BUTTON: (element: HTMLInputElement) => ({ value: element.value, checked: element.checked }),

I found that when adding checked: element.checked, a TypeScript error appears stating that "Property 'checked' does not exist on type 'HTMLButtonElement', may need to find another workaround.

DennisHC avatar Jul 29 '23 04:07 DennisHC

Proposed change: INPUT: (element: HTMLInputElement) => ({ value: element.value, checked: element.checked })

Since the issue is referred to the checkboxes needing a checked attribute, I believe this may fix it here.

DennisHC avatar Jul 30 '23 05:07 DennisHC

That seems correct to me.

rmorshea avatar Jul 30 '23 21:07 rmorshea