Skip to content

Commit

Permalink
fix: add missing uuid to alert
Browse files Browse the repository at this point in the history
  • Loading branch information
nmerget committed Feb 27, 2024
1 parent 07d81da commit f4c22c3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/components/src/components/alert/alert.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
import { DBAlertProps, DBAlertState } from './model';
import { DBButton } from '../button';
import { DBLink } from '../link';
import { DEFAULT_CLOSE_BUTTON } from '../../shared/constants';
import { cls } from '../../utils';
import { DEFAULT_CLOSE_BUTTON, DEFAULT_ID } from '../../shared/constants';
import { cls, uuid } from '../../utils';
import { ClickEvent } from '../../shared/model';

useMetadata({
Expand All @@ -20,6 +20,7 @@ export default function DBAlert(props: DBAlertProps) {
const ref = useRef<HTMLDivElement>(null);
// jscpd:ignore-start
const state = useStore<DBAlertState>({
_id: DEFAULT_ID,
handleClick: (event: ClickEvent<HTMLButtonElement>) => {
if (props.onClick) {
props.onClick(event);
Expand All @@ -28,6 +29,7 @@ export default function DBAlert(props: DBAlertProps) {
});

onMount(() => {
state._id = props.id || 'alert-' + uuid();
if (props.stylePath) {
state.stylePath = props.stylePath;
}
Expand All @@ -37,7 +39,7 @@ export default function DBAlert(props: DBAlertProps) {
return (
<div
ref={ref}
id={props.id}
id={state._id}
class={cls('db-alert', props.className)}
aria-live={props.ariaLive}
data-variant={props.variant}
Expand Down

0 comments on commit f4c22c3

Please sign in to comment.