Skip to content

Conversation

@genu
Copy link
Member

@genu genu commented Jun 1, 2025

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR improves the way props are handled. Since props can be set on create and on open, I believe the expectation is that when props are not passed to open, then the ones passed to create are used. Furthermore, when passing props to open it should not override the original props that were passed to create, they should only be applied for that instance.

Take this example:

When creating an overlay like so:

const modal = overlay.create(MyModal, {
  props: {
    count: 12
  }
})

const openSecond = () => {
   modal.open({ count: 22})
}

const openOriginal = () => {
   modal.open()
}

If we open in this order:

1. openSecond // count is 22
2. openOriginal // count is still 22 because the first time we called open, the props were overridden

The expected behavior is that when calling open() without props, it would always default to using the props that were set at creation.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@genu genu requested a review from benjamincanac as a code owner June 1, 2025 12:26
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jun 1, 2025

npm i https://pkg.pr.new/@nuxt/ui@4269

commit: 0458249

@genu genu changed the title feat(useOverlay): use original props when they are not provided to open fix(useOverlay): use original props when they are not provided to open Jun 4, 2025
@benjamincanac benjamincanac changed the title fix(useOverlay): use original props when they are not provided to open fix(useOverlay): use original props when not provided to open Jun 5, 2025
@benjamincanac benjamincanac merged commit bf56e15 into nuxt:v3 Jun 5, 2025
6 checks passed
@Shedevro
Copy link

Shedevro commented Jun 6, 2025

@benjamincanac @genu,
Hello guys.
I have this code

  overlay.create(PdfViewerDialog, {
      props: {
        files,
      },
      defaultOpen: true,
      destroyOnClose: true,
    });

Now I'm getting error and unable to use useOverlay().

[Vue warn]: Missing required prop: "files" 
  at <PdfViewerDialog key= Symbol() ref_for=true open=true  ... >

It works fine with public v3.

@genu
Copy link
Member Author

genu commented Jun 6, 2025

@Shedevro is that issue related specifically to this PR?

In my testing, I'm not able to reproduce the issue.

Do you mind opening up a issue with a reproduction?

@genu genu deleted the feature/make-open-props-temporary branch June 6, 2025 13:36
@Shedevro
Copy link

Shedevro commented Jun 6, 2025

@genu
Yes, it's related to this PR.
I'm using Vue.
I've downgraded to the previous commit (09151df) and it works fine.
I don't think creating an issue is a good idea cuz this is not a public version.
Reproduction is simple - it's just overlay.create() call with a component with props.

@Shedevro
Copy link

Shedevro commented Jun 6, 2025

@genu
I don't think I understood your code well. But you just pass props: {} on overlay open.
Note that I'm passing defaultOpen: true

@genu
Copy link
Member Author

genu commented Jun 6, 2025

@Shedevro Can you verify if the issue is fixed in above PR?

@Shedevro
Copy link

Shedevro commented Jun 7, 2025

@genu it works now, thank you.

@benjamincanac benjamincanac added the v3 #1289 label Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v3 #1289

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants