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 6f81876
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use client';

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

import { getAsset, Loader, LoadingWrapper } from './assets';
import { getAsset, Loader, LoadingWrapper, CloseIcon } from './assets';
import { useIsDocumentHidden } from './hooks';
import { toast, ToastState } from './state';
import './styles.css';
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 6f81876

Please sign in to comment.