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 tooltip onPopupAlign never called #7112

Merged
merged 1 commit into from
Dec 18, 2023

Conversation

oliyg
Copy link
Contributor

@oliyg oliyg commented Nov 15, 2023

We have defined onPopupAlign function in Tooltip component.

// components/tooltip/Tooltip.tsx
export default defineComponent({
  setup() {
    const onPopupAlign = (domNode: HTMLElement, align: any) => {};
    const vcTooltipProps = {
      onPopupAlign,
    };
    return wrapSSR(<VcTooltip {...vcTooltipProps}>{/* ... */}</VcTooltip>);
  },
});

But this function will never invoked.

Because the props of PopupInner component do not accept onAlign prop. We need have to include it.

// components/vc-trigger/Popup/interface.ts
export const innerProps = {
  // Align
+  onAlign: {
+    type: Function as PropType<(popupDomNode: HTMLElement, align: AlignType) => void>,
+  },
};

In this way, we can trigger this function from here:

// components/vc-trigger/Popup/PopupInner.tsx
const onInternalAlign = (popupDomNode: HTMLElement, matchAlign: AlignType) => {
  if (status.value === "align") {
    props.onAlign?.(popupDomNode, matchAlign); // trigger
  }
};

Or we can also remove this part:

// components/tooltip/Tooltip.tsx
export default defineComponent({
  setup() {
-    const onPopupAlign = (domNode: HTMLElement, align: any) => {};
    const vcTooltipProps = {
      onPopupAlign,
    };
    return wrapSSR(<VcTooltip {...vcTooltipProps}>{/* ... */}</VcTooltip>);
  },
});

Verified

This commit was signed with the committer’s verified signature.
VietND96 Viet Nguyen Duc
@tangjinzhou tangjinzhou merged commit a8a774a into vueComponent:main Dec 18, 2023
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants