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

It's necessary for the next button to be inside ? #9

Open
zougari47 opened this issue Feb 17, 2024 · 6 comments
Open

It's necessary for the next button to be inside ? #9

zougari47 opened this issue Feb 17, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@zougari47
Copy link

When I try to place the next button outside the stepper, it doesn't work for me. The UI I have requires the next button to be positioned outside the steps.

@efstajas
Copy link
Owner

As-is, generally yeah, because the way the step controller functions is by dispatching events, which get consumed by the stepper. So the events need to originate from step components which are nested below the stepper.

However, there's probably a way to work around this. Without having thought about this a lot, I would try something like catching the step controller's events (you can find them here), and exporting a function from your step components that just re-emits any event you pass it, and then using this function to re-emit events within the scope of the stepper.

Another approach could be to use a svelte portal to "portal" the next / previous buttons from within the step components to elsewhere into the DOM.

@efstajas
Copy link
Owner

efstajas commented Mar 7, 2024

Closing for now, lmk if you run into any trouble with the suggestions 👍

@efstajas efstajas closed this as completed Mar 7, 2024
@lucabrini
Copy link

I think this could be a pretty nice feature

@lucabrini
Copy link

However, there's probably a way to work around this. Without having thought about this a lot, I would try something like catching the step controller's events (you can find them here), and exporting a function from your step components that just re-emits any event you pass it, and then using this function to re-emit events within the scope of the stepper.

Can you please provide me an example? I'm kinda new to Svelte

@efstajas efstajas reopened this Jul 2, 2024
@efstajas
Copy link
Owner

efstajas commented Jul 2, 2024

Re-opening this since I'm thinking exporting a stepController-like object from the Stepper, which could be used in addition or instead of the event-based API, would probably be relatively trivial and solve this need.

@lucabrini I think the easiest approach for now would be to use a "portal", like this one: https://github.com/romkor/svelte-portal

The steps would simply be:

  1. Create an empty div with an explicit ID like #nav-buttons somewhere on your page
  2. Within your step components, put the navigation buttons within a Portal component that points to the div ID from step 1

Disclaimer: I haven't tried it yet, but I can't see why it wouldn't work.

@efstajas efstajas added the enhancement New feature or request label Jul 2, 2024
@lucabrini
Copy link

Re-opening this since I'm thinking exporting a stepController-like object from the Stepper, which could be used in addition or instead of the event-based API, would probably be relatively trivial and solve this need.

Cool!

@lucabrini I think the easiest approach for now would be to use a "portal", like this one: https://github.com/romkor/svelte-portal

Thank you so much, didn't know about portals :)

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

No branches or pull requests

3 participants