Skip to content

useOverlay props type lost #3436

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

Closed
eevho opened this issue Mar 3, 2025 · 9 comments
Closed

useOverlay props type lost #3436

eevho opened this issue Mar 3, 2025 · 9 comments
Labels
bug Something isn't working v3 #1289

Comments

@eevho
Copy link

eevho commented Mar 3, 2025

Environment


  • Operating System: Linux
  • Node Version: v20.9.0
  • Nuxt Version: 3.15.4
  • CLI Version: 3.22.3
  • Nitro Version: 2.10.4
  • Package Manager: [email protected]
  • Builder: -
  • User Config: devtools, vite, modules, css, compatibilityDate
  • Runtime Modules: @nuxt/[email protected]
  • Build Modules: -

Is this bug related to Nuxt or Vue?

Nuxt

Version

3.15.4

Reproduction

https://codesandbox.io/p/devbox/pmvsfw

Description

declare function _useOverlay(): {
    overlays: import("vue").ShallowReactive<Overlay[]>;
    open: <T extends Component>(id: symbol, props?: ComponentProps<T>) => Promise<any>;
    close: (id: symbol, value?: any) => void;
    create: <T extends Component>(component: T, _options?: OverlayOptions<ComponentProps<T>>) => OverlayInstance<T>;
    patch: <T extends Component>(id: symbol, props: Partial<ComponentProps<T>>) => void;
    unMount: (id: symbol) => void;
};

e.g:

const overlay = useOverlay()
overlay.create(UModal, { props: {untyped} })

I didn't get the correct props type when using useOverlay, and there are no property hints when passing overlay.open or the open function after create

Additional context

No response

Logs

@eevho eevho added bug Something isn't working triage v3 #1289 labels Mar 3, 2025
@eevho eevho changed the title UseOverlay props type lost useOverlay props type lost Mar 3, 2025
@genu
Copy link
Contributor

genu commented Mar 3, 2025

I think the issue is that you're passing UModal to the overlay. What you have to do is actually create a component and pass it to the overlay, like so:

import { Confirm } from "#components";

export const useConfirm = () => {
  const overlay = useOverlay();
  const m = overlay.create(Confirm, {
    props: {
      title:'test'
    }
  });
  // The visible type hint is any
  m.open({
    
  });
};

Have a look at this: https://codesandbox.io/p/devbox/nuxtui-useoverlay-forked-8gh75m

and the docs: https://ui3.nuxt.dev/components/modal#programmatic-usage

@eevho
Copy link
Author

eevho commented Mar 4, 2025

Image

I mean props didn't get the correct type, it's now any, and the same goes for passing the components it created

@genu
Copy link
Contributor

genu commented Mar 4, 2025

Hmm, it's odd. I'll take a look.

Could you try it directly in vscode instead of codesandbox in the meantime?

Copy link
Author

eevho commented Mar 4, 2025

I found this problem in the local vscode, because codesandbox is convenient to view the ts prompt, so use it to reproduce.

@genu
Copy link
Contributor

genu commented Mar 4, 2025

What was the problem?

@eevho
Copy link
Author

eevho commented Mar 4, 2025

I mean the missing props type was first discovered in my local vscode environment

@genu
Copy link
Contributor

genu commented Mar 28, 2025

Is it safe to say this can be closed? cc @benjamincanac

Copy link
Member

@genu Fixed by #3716 right?

@genu
Copy link
Contributor

genu commented Mar 28, 2025

@genu Fixed by #3716 right?

This is unrelated to that PR.

This was probably related to codesandbox environment. There haven't been any other reports beyond this -- probably a very isolated issue.

@benjamincanac benjamincanac removed the triage label Apr 22, 2025 — with Volta.net
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v3 #1289
Projects
None yet
Development

No branches or pull requests

3 participants