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

feat(Slideovers): Allow multiple instances of programmatic slideover #1758

Open
wants to merge 20 commits into
base: dev
Choose a base branch
from

Conversation

genu
Copy link
Contributor

@genu genu commented May 7, 2024

πŸ”— Linked issue

❓ 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 opens the possibility to open multiple instance of the <Slideover/> component using the useSlideover() composable.

This capability was discussed in the past, so this is an attempt at such a feature.

πŸ“ Checklist

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

@genu
Copy link
Contributor Author

genu commented May 7, 2024

Tagging @noook for feedback

@genu genu changed the title Feature/multi slideover Feature: Allow Multiple instances of programmatic slideover May 7, 2024
@genu genu changed the title Feature: Allow Multiple instances of programmatic slideover Feature: Allow multiple instances of programmatic slideover May 7, 2024
src/runtime/composables/useSlideover.ts Show resolved Hide resolved
src/runtime/types/slideover.d.ts Show resolved Hide resolved
src/runtime/composables/useSlideover.ts Outdated Show resolved Hide resolved
src/runtime/composables/useSlideover.ts Outdated Show resolved Hide resolved
src/runtime/composables/useSlideover.ts Outdated Show resolved Hide resolved
src/runtime/components/overlays/Slideovers.client.vue Outdated Show resolved Hide resolved
src/runtime/composables/useSlideover.ts Outdated Show resolved Hide resolved
@genu genu force-pushed the feature/multi-slideover branch from 74aee7b to 7253ac5 Compare May 9, 2024 02:42
@genu
Copy link
Contributor Author

genu commented May 9, 2024

@noook Thanks for the comments, I made most changes.

I'm thinking, would it make better sense to create instances without open?

This would allow us do declare instances like this:

const slideover = useSlideover()
const slideoverA = slideover.create(SlideoverExampleComponent)

const openSlideover = () => {
  const slideoverA = slideover.open()
}

const doSomethingElse = () => {
   slideOverA.patch({..})
}

const doAnotherThing = () => {
   slideOverA.close()
}

@noook
Copy link
Collaborator

noook commented May 10, 2024

There is an issue: Slideovers should be dismissable when clicking outside unless you explicitly prevent them from closing with the appropriate prop.

Your example components do not specify it so it should keep the original behaviour:
https://ui-9x1er5zyw-nuxt-js.vercel.app/dev/components/slideover#control-programmatically

@genu genu changed the title Feature: Allow multiple instances of programmatic slideover feat(Slideovers): Allow multiple instances of programmatic slideover May 13, 2024
The code changes in `Slideovers.client.vue` remove the unused `<pre>` element that displayed the `slideoverInstances` props. This cleanup improves code readability and removes unnecessary code.
@genu
Copy link
Contributor Author

genu commented May 13, 2024

There is an issue: Slideovers should be dismissable when clicking outside unless you explicitly prevent them from closing with the appropriate prop.

Your example components do not specify it so it should keep the original behaviour: https://ui-9x1er5zyw-nuxt-js.vercel.app/dev/components/slideover#control-programmatically

I fixed it by listening to model changes on the modal and closing it when the model is changed. An issue I run into is that when clicking on the outside, it always closes the first one that was open, rather than the last one (i.e. the one on top).

This issue would probably happen if we implement something similar in UModal. I'm digging through how the outside click is handled in the component and see if there is anything to be done there.

@noook Open to suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants