Skip to content

Commit f736ca4

Browse files
authored
fix: missing align style (#576)
* fix: missing align style * test: simplify test case * test: rename
1 parent 3d9e4b0 commit f736ca4

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

src/UniqueProvider/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ const UniqueProvider = ({ children }: UniqueProviderProps) => {
216216
offsetY={offsetY}
217217
popupSize={popupSize}
218218
motion={options.popupMotion}
219-
uniqueBgClassName={options.uniqueBgClassName}
219+
uniqueBgClassName={classNames(
220+
options.uniqueBgClassName,
221+
alignedClassName,
222+
)}
220223
uniqueBgStyle={options.uniqueBgStyle}
221224
/>
222225
</Popup>

tests/unique.test.tsx

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ describe('Trigger.Unique', () => {
125125

126126
// There should only be one popup element
127127
expect(document.querySelectorAll('.rc-trigger-popup').length).toBe(1);
128-
expect(document.querySelectorAll('.rc-trigger-popup-unique-body').length).toBe(
129-
1,
130-
);
128+
expect(
129+
document.querySelectorAll('.rc-trigger-popup-unique-body').length,
130+
).toBe(1);
131131

132132
// FloatBg open prop should not have changed during transition (no close animation)
133133
expect(global.openChangeLog).toHaveLength(0);
@@ -192,7 +192,9 @@ describe('Trigger.Unique', () => {
192192
});
193193

194194
it('should apply uniqueBgStyle to UniqueBody component', async () => {
195-
await setupAndOpenPopup({ uniqueBgStyle: { backgroundColor: 'red', border: '1px solid blue' } });
195+
await setupAndOpenPopup({
196+
uniqueBgStyle: { backgroundColor: 'red', border: '1px solid blue' },
197+
});
196198

197199
// Check that UniqueBody has the custom background style
198200
const uniqueBody = document.querySelector('.rc-trigger-popup-unique-body');
@@ -211,4 +213,38 @@ describe('Trigger.Unique', () => {
211213
expect(uniqueBody).toBeTruthy();
212214
expect(uniqueBody.className).not.toContain('undefined');
213215
});
216+
217+
it('should pass alignedClassName on unique body', async () => {
218+
const getPopupClassNameFromAlign = () => 'bamboo';
219+
220+
render(
221+
<UniqueProvider>
222+
<Trigger
223+
action={['click']}
224+
popup={<strong className="x-content">tooltip</strong>}
225+
unique
226+
popupVisible
227+
popupPlacement="bottomLeft"
228+
getPopupClassNameFromAlign={getPopupClassNameFromAlign}
229+
builtinPlacements={{
230+
bottomLeft: {
231+
points: ['tl', 'bl'],
232+
offset: [0, 4],
233+
overflow: {
234+
adjustX: 0,
235+
adjustY: 1,
236+
},
237+
},
238+
}}
239+
>
240+
<div className="target">click me</div>
241+
</Trigger>
242+
</UniqueProvider>,
243+
);
244+
245+
expect(document.querySelector('.rc-trigger-popup')).toHaveClass('bamboo');
246+
expect(document.querySelector('.rc-trigger-popup-unique-body')).toHaveClass(
247+
'bamboo',
248+
);
249+
});
214250
});

0 commit comments

Comments
 (0)