Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Popup/Arrow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface ArrowProps {
export default function Arrow(props: ArrowProps) {
const { prefixCls, align, arrow, arrowPos } = props;

const { className, content } = arrow || {};
const { className, content, style } = arrow || {};
const { x = 0, y = 0 } = arrowPos;

const arrowRef = React.useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -58,7 +58,7 @@ export default function Arrow(props: ArrowProps) {
<div
ref={arrowRef}
className={classNames(`${prefixCls}-arrow`, className)}
style={alignStyle}
style={{ ...alignStyle, ...style }}
>
{content}
</div>
Expand Down
1 change: 1 addition & 0 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export interface AlignType {
}

export interface ArrowTypeOuter {
style?: React.CSSProperties;
className?: string;
content?: React.ReactNode;
}
Expand Down
60 changes: 60 additions & 0 deletions tests/arrow.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,66 @@ describe('Trigger.Arrow', () => {
const arrowDom = document.querySelector('.rc-trigger-popup-arrow');
expect(arrowDom.classList.contains('abc')).toBeTruthy();
});

it('arrow style', async () => {
render(
<Trigger
popupVisible
popupAlign={{
points: ['cl', 'cr'],
autoArrow: false,
}}
popup={<strong>trigger</strong>}
arrow={{
style: {
color: 'red',
backgroundColor: 'blue',
},
}}
>
<div />
</Trigger>,
);

await awaitFakeTimer();

const arrowDom = document.querySelector('.rc-trigger-popup-arrow');
expect(arrowDom).toHaveStyle({
color: 'red',
backgroundColor: 'blue',
});
});

it('arrow style should merge with align style', async () => {
render(
<Trigger
popupVisible
popupAlign={{
points: ['cl', 'cr'],
autoArrow: true,
}}
popup={<strong>trigger</strong>}
arrow={{
style: {
color: 'red',
backgroundColor: 'blue',
},
}}
>
<div />
</Trigger>,
);

await awaitFakeTimer();

const arrowDom = document.querySelector('.rc-trigger-popup-arrow');
// Should have both align style (left: 0) and custom style
expect(arrowDom).toHaveStyle({
left: 0,
color: 'red',
backgroundColor: 'blue',
});
});
});

it('content', async () => {
Expand Down
Loading