Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix open/close event emitting in Safari #7551

Merged
Merged
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
15 changes: 11 additions & 4 deletions packages/calcite-components/src/utils/openCloseComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,18 @@ function emitImmediately(component: OpenCloseComponent, nonOpenCloseComponent =
export function onToggleOpenCloseComponent(component: OpenCloseComponent, nonOpenCloseComponent = false): void {
readTask((): void => {
if (component.transitionEl) {
const allTransitionPropsArray = getComputedStyle(component.transitionEl).transition.split(" ");
const openTransitionPropIndex = allTransitionPropsArray.findIndex(
(item) => item === component.openTransitionProp
const { transitionDuration: allDurations, transitionProperty: allProps } = getComputedStyle(
component.transitionEl
);
const transitionDuration = allTransitionPropsArray[openTransitionPropIndex + 1];
const allTransitionDurationsArray = allDurations.split(",");
const allTransitionPropsArray = allProps.split(",");
const openTransitionPropIndex = allTransitionPropsArray.indexOf(component.openTransitionProp);

const transitionDuration =
allTransitionDurationsArray[openTransitionPropIndex] ??
/* Safari will have a single transition value if multiple props share it,
so we fall back to it if there's no matching prop duration */
allTransitionDurationsArray[0];

if (transitionDuration === "0s") {
emitImmediately(component, nonOpenCloseComponent);
Expand Down