Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] OuiCheckableCard onChange fire twice after checkbox clicked #1278

Open
wanglam opened this issue May 11, 2024 · 1 comment
Open

[BUG] OuiCheckableCard onChange fire twice after checkbox clicked #1278

wanglam opened this issue May 11, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@wanglam
Copy link

wanglam commented May 11, 2024

Describe the bug
The onChange property of OuiCheckableCard will be triggered twice after checkbox clicked. The onChange callback should only be fired once for single checkbox click. It seems the duplicated onChange was be fired by [this line].(https://github.com/opensearch-project/oui/blob/main/src/components/card/checkable_card/checkable_card.tsx#L113)

To Reproduce

Here is the sample code:

import React, { useState } from 'react';

import { OuiCheckableCard } from '@opensearch-project/oui';

import { htmlIdGenerator } from '@opensearch-project/oui/lib/services';

export default () => {
  return (
    <OuiCheckableCard
      id={htmlIdGenerator()()}
      label="I am a checkbox"
      checkableType="checkbox"
      value="checkbox1"
      checked={checkbox}
      onChange={() => {
        console.log("on change called.");
      }}
    />
  );
};

The on change called will output twice after checkbox clicked.

Expected behavior

It should only fired once for single checkbox click.

Screenshots

image

Host/Environment (please complete the following information):

  • OUI Version: [e.g. 1.0]
  • OSD Version (if applicable): [e.g. 2.7.0]
  • OS: [e.g. iOS]
  • Browser and version [e.g. Chrome 90]

Additional context
N/A

@wanglam wanglam added bug Something isn't working untriaged labels May 11, 2024
@dblock
Copy link
Member

dblock commented Jun 24, 2024

Catch All Triage - 1 2 3 4 5 6

@dblock dblock removed the untriaged label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants