From 79e111cc5c4d901e9cf6a7cab87a7baed1cb280f Mon Sep 17 00:00:00 2001 From: Adrien Denat Date: Thu, 19 Jan 2023 13:34:14 +0000 Subject: [PATCH] fix(react): fix support for custom classNames --- packages/simplebar-react/index.tsx | 29 +++--- .../tests/__snapshots__/index.test.tsx.snap | 89 +++++-------------- 2 files changed, 39 insertions(+), 79 deletions(-) diff --git a/packages/simplebar-react/index.tsx b/packages/simplebar-react/index.tsx index 6670e015..9d7edb67 100644 --- a/packages/simplebar-react/index.tsx +++ b/packages/simplebar-react/index.tsx @@ -54,6 +54,11 @@ const SimpleBar = React.forwardRef( } }); + const classNames = { + ...SimpleBarCore.defaultOptions.classNames, + ...options.classNames, + }; + React.useEffect(() => { let instance: SimpleBarCore | null; scrollableNodeRef.current = scrollableNodeFullProps.ref @@ -89,12 +94,12 @@ const SimpleBar = React.forwardRef( return (
-
-
-
+
+
+
-
-
+
+
{typeof children === 'function' ? ( children({ scrollableNodeRef, @@ -104,24 +109,24 @@ const SimpleBar = React.forwardRef( }, contentNodeRef, contentNodeProps: { - className: 'simplebar-content', + className: classNames.contentEl, ref: contentNodeRef, }, }) ) : (
-
{children}
+
{children}
)}
-
+
-
-
+
+
-
-
+
+
); diff --git a/packages/simplebar-react/tests/__snapshots__/index.test.tsx.snap b/packages/simplebar-react/tests/__snapshots__/index.test.tsx.snap index 70151665..78428540 100644 --- a/packages/simplebar-react/tests/__snapshots__/index.test.tsx.snap +++ b/packages/simplebar-react/tests/__snapshots__/index.test.tsx.snap @@ -1,7 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`renders with object as option 1`] = ` -
+
@@ -29,69 +31,21 @@ exports[`renders with object as option 1`] = `
-
-
-
-
-
-
-
-
-

- Some content -

-

- Some content -

-

- Some content -

-

- Some content -

-

- Some content -

-
-
-
-
-
-
-
-
-
-
-
-
+

+ Some content +

+

+ Some content +

+

+ Some content +

+

+ Some content +

+

+ Some content +

@@ -125,10 +79,10 @@ exports[`renders with object as option 1`] = ` exports[`renders with options 1`] = `
-
+