Skip to content

fix(CToast): change special prop key to innerKey #405

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

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/coreui-react/src/components/toast/CToast.tsx
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ export interface CToastProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title
/**
* @ignore
*/
key?: number
innerKey?: number | string
/**
* Callback fired when the component requests to be closed.
*/
@@ -76,7 +76,7 @@ export const CToast = forwardRef<HTMLDivElement, CToastProps>(
color,
delay = 5000,
index,
key,
innerKey,
visible = false,
onClose,
onShow,
@@ -143,7 +143,7 @@ export const CToast = forwardRef<HTMLDivElement, CToastProps>(
onMouseEnter={() => clearTimeout(timeout.current)}
onMouseLeave={() => _autohide()}
{...rest}
key={key}
key={innerKey}
ref={forkedRef}
>
{children}
@@ -163,7 +163,10 @@ CToast.propTypes = {
color: colorPropType,
delay: PropTypes.number,
index: PropTypes.number,
key: PropTypes.number,
innerKey: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]),
onClose: PropTypes.func,
onShow: PropTypes.func,
visible: PropTypes.bool,
2 changes: 1 addition & 1 deletion packages/coreui-react/src/components/toast/CToaster.tsx
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ export const CToaster = forwardRef<HTMLDivElement, CToasterProps>(
...state,
React.cloneElement(push, {
index: index.current,
key: index.current,
innerKey: index.current,
onClose: (index: number) =>
setToasts((state) => state.filter((i) => i.props.index !== index)),
}),