Skip to content

Commit

Permalink
feat: allow ref forwarding for Toaster (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
freshgiammi authored and eliezerbasubi committed Dec 23, 2024
1 parent cc734a6 commit fbe0c0d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import React from 'react';
import React, { forwardRef } from 'react';
import ReactDOM from 'react-dom';

import { getAsset, Loader, LoadingWrapper } from './assets';
Expand Down Expand Up @@ -466,7 +466,7 @@ function useSonner() {
};
}

const Toaster = (props: ToasterProps) => {
const Toaster = forwardRef<HTMLElement, ToasterProps>(function Toaster(props, ref) {
const {
invert,
position = 'bottom-right',
Expand Down Expand Up @@ -624,7 +624,7 @@ const Toaster = (props: ToasterProps) => {

return (
// Remove item from normal navigation flow, only available via hotkey
<section aria-label={`${containerAriaLabel} ${hotkeyLabel}`} tabIndex={-1}>
<section aria-label={`${containerAriaLabel} ${hotkeyLabel}`} tabIndex={-1} ref={ref}>
{possiblePositions.map((position, index) => {
const [y, x] = position.split('-');
return (
Expand Down Expand Up @@ -723,6 +723,6 @@ const Toaster = (props: ToasterProps) => {
})}
</section>
);
};
});
export { toast, Toaster, type ExternalToast, type ToastT, type ToasterProps, useSonner };
export { type ToastClassnames, type ToastToDismiss, type Action } from './types';

0 comments on commit fbe0c0d

Please sign in to comment.