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

Tooltip does not work when its children component is a custom component #1985

Open
carolvalenca opened this issue Oct 1, 2024 · 2 comments
Labels
bug Something isn't working dev Indicates that the issue or pull request involves engineering considerations

Comments

@carolvalenca
Copy link

carolvalenca commented Oct 1, 2024

Problem

Utilizando o componente Tooltip recentemente notei que quando o componente encapsulado no Tooltip é customizado (importado de outro arquivo ou até mesmo estando no mesmo arquivo mas sendo separado em outra função), o Tooltip não aparece.

Expected behavior

Quando houver o hover em um componente encapsulado no Tooltip, o Tooltip é mostrado em tela.

Reproducible Example

https://codesandbox.io/p/sandbox/6s4hp5

Suggested solution

No response

Additional context

Estou utilizando localmente a versão 1.5.0 do @vtex/shoreline e no snippet do CodeSandbox a versão 1.9.10. Em ambas versões o erro acontece.

Package

@vtex/shoreline

Packages version

No response

Browser

Chrome

Package Manager

pnpm

@carolvalenca carolvalenca added the bug Something isn't working label Oct 1, 2024
@beatrizmilhomem beatrizmilhomem added the dev Indicates that the issue or pull request involves engineering considerations label Oct 9, 2024
@lucasaarcoverde
Copy link
Contributor

oii @carolvalenca, o Tooltip utiliza a referência pra posicionar o popover, por isso é necessário utilizar um forwardRef ao criar o custom component

https://codesandbox.io/p/sandbox/6s4hp5

em typescript ficaria assim

import { Button } from "@vtex/shoreline";
import "@vtex/shoreline/css";
import { Ref, forwardRef } from "react";

const CustomButton = forwardRef(function CustomButton(props: ButtonProps, ref: Ref<HTMLButtonElement>) {
  return (
    <Button {...props} ref={ref}>
      Custom button imported from another file
    </Button>
  );
});

export default CustomButton;

@davicostalf
Copy link
Contributor

@carolvalenca A resposta de lucas responde seu problema?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dev Indicates that the issue or pull request involves engineering considerations
Projects
Status: No status
Development

No branches or pull requests

4 participants