Skip to content

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

Closed

Description

@Archmonger

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.

Activity

  1. rmorshea commented on Jun 19, 2023

    @rmorshea
    Collaborator

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

  2. Archmonger commented on Jun 19, 2023

    @Archmonger
    ContributorAuthor

    @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.

  3. DennisHC commented on Jul 29, 2023

    @DennisHC
    Contributor

    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.

  4. DennisHC commented on Jul 30, 2023

    @DennisHC
    Contributor

    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.

  5. rmorshea commented on Jul 30, 2023

    @rmorshea
    Collaborator

    That seems correct to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions