Skip to content

Commit aac9d88

Browse files
committed
fix: missing align style
1 parent 3d9e4b0 commit aac9d88

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
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: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,56 @@ describe('Trigger.Unique', () => {
211211
expect(uniqueBody).toBeTruthy();
212212
expect(uniqueBody.className).not.toContain('undefined');
213213
});
214+
215+
it('should combine alignedClassName with uniqueBgClassName', async () => {
216+
const getPopupClassNameFromAlign = (align: any) => {
217+
return `custom-align-${align.points?.[0] || 'default'}`;
218+
};
219+
220+
const { container } = render(
221+
<UniqueProvider>
222+
<Trigger
223+
action={['click']}
224+
popup={<strong className="x-content">tooltip</strong>}
225+
unique
226+
popupPlacement="bottomLeft"
227+
builtinPlacements={{
228+
bottomLeft: {
229+
points: ['tl', 'bl'],
230+
offset: [0, 4],
231+
overflow: {
232+
adjustX: 0,
233+
adjustY: 1,
234+
},
235+
},
236+
}}
237+
getPopupClassNameFromAlign={getPopupClassNameFromAlign}
238+
uniqueBgClassName="custom-bg-class"
239+
>
240+
<div className="target">click me</div>
241+
</Trigger>
242+
</UniqueProvider>,
243+
);
244+
245+
// Initially no popup should be visible
246+
expect(document.querySelector('.rc-trigger-popup')).toBeFalsy();
247+
248+
// Click trigger to show popup
249+
fireEvent.click(container.querySelector('.target'));
250+
await awaitFakeTimer();
251+
252+
// Wait a bit more for alignment to complete
253+
await awaitFakeTimer();
254+
255+
// Check that popup exists
256+
const popup = document.querySelector('.rc-trigger-popup');
257+
expect(popup).toBeTruthy();
258+
expect(popup.querySelector('.x-content').textContent).toBe('tooltip');
259+
260+
// Check that both custom background className and aligned className are applied to UniqueBody
261+
const uniqueBody = document.querySelector('.rc-trigger-popup-unique-body');
262+
expect(uniqueBody).toBeTruthy();
263+
expect(uniqueBody.className).toContain('custom-bg-class');
264+
expect(uniqueBody.className).toContain('custom-align');
265+
});
214266
});

0 commit comments

Comments
 (0)