Skip to content

Commit

Permalink
consistent p-component-overlay-leave handling (#5969)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Feb 14, 2024
1 parent de59954 commit 67117a2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
9 changes: 7 additions & 2 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1874,9 +1874,14 @@ export const Calendar = React.memo(
destroyMask();
} else {
!isUnstyled() && DomHandler.addClass(touchUIMask.current, 'p-component-overlay-leave');
touchUIMask.current.addEventListener('animationend', () => {

if (DomHandler.hasCSSAnimation(touchUIMask.current) > 0) {
touchUIMask.current.addEventListener('animationend', () => {
destroyMask();
});
} else {
destroyMask();
});
}
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion components/lib/dialog/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export const Dialog = React.forwardRef((inProps, ref) => {

const onExiting = () => {
if (props.modal) {
DomHandler.addClass(maskRef.current, 'p-component-overlay-leave');
!isUnstyled() && DomHandler.addClass(maskRef.current, 'p-component-overlay-leave');
}
};

Expand Down
2 changes: 1 addition & 1 deletion components/lib/image/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const Image = React.memo(
};

const onExit = () => {
DomHandler.addClass(maskRef.current, 'p-component-overlay-leave');
!isUnstyled() && DomHandler.addClass(maskRef.current, 'p-component-overlay-leave');
};

const onExiting = () => {
Expand Down
2 changes: 1 addition & 1 deletion components/lib/sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const Sidebar = React.forwardRef((inProps, ref) => {

const onExiting = () => {
if (props.modal) {
DomHandler.addClass(maskRef.current, 'p-component-overlay-leave');
!isUnstyled() && DomHandler.addClass(maskRef.current, 'p-component-overlay-leave');
}
};

Expand Down
17 changes: 7 additions & 10 deletions components/lib/sidebar/Sidebar.spec.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
import { Sidebar } from './sidebar';
import { Sidebar } from './Sidebar';

describe('Sidebar', () => {
test(
'can be made visible',
() => {
const hideOn = jest.fn();
test('can be made visible', () => {
const hideOn = jest.fn();

render(<Sidebar visible={true} onHide={hideOn} />);
render(<Sidebar visible={true} onHide={hideOn} />);

const sidebar = screen.queryByRole('complementary');
const sidebar = screen.queryByRole('complementary');

expect(sidebar).toBeVisible();
}
);
expect(sidebar).toBeVisible();
});
});

0 comments on commit 67117a2

Please sign in to comment.