# Navigation issue on single page app

**URL:** <https://forum.bubble.io/t/navigation-issue-on-single-page-app/195013>\
**Category:** Database\
**Created:** [March 7, 2022, 8:19pm UTC](https://forum.bubble.io/t/navigation-issue-on-single-page-app/195013 "2022-03-07T20:19:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![darren.james7518](https://avatars.discourse-cdn.com/v4/letter/d/a3d4f5/32.png) [@darren.james7518](https://forum.bubble.io/u/darren.james7518)\
**Post date:** [March 7, 2022, 8:19pm UTC](https://forum.bubble.io/t/navigation-issue-on-single-page-app/195013/1 "2022-03-07T20:19:53Z")

</div>

I have a single page app and I am setting a state on each group called selectedGroup.

I have a floating group navigation with a text link called ‘Next’ which is displayed on all pages. I want to use custom states so that the ‘Next’ link goes to the correct group.

Here’s the issue;

When you are on group1 and click ‘Next’, it will take you to group2, but then immediately go to group3 and then group4 (without stopping).

I’ve tried making use of a previousGroup state but it makes no difference. I wonder if anyone can suggest a way to ensure the workflow stops on the next group before continuing on to the next?

Here’s a very simplified mock-up of the navigation;

> **[Bubble Editor - Navigation0703202](https://bubble.io/page?name=index&id=navigation0703202&tab=tabs-6&subtab=General)**
>
> Build stuff without code and launch a startup without a tech-cofounder! Bubble is a visual programing language. Instead of typing code, use a visual editor to build applications.

---

<div class="post-metadata">

**Author:** ![mikeloc](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mikeloc/32/93001_2.png) [@mikeloc](https://forum.bubble.io/u/mikeloc)\
**Post date:** [March 7, 2022, 9:03pm UTC](https://forum.bubble.io/t/navigation-issue-on-single-page-app/195013/2 "2022-03-07T21:03:16Z")

</div>

Hi there, @darren.james7518… the reason it’s not stopping is because you are setting the state to three different values within the same workflow. So, try this… make two copies of the _When Text Next\> is clicked_ workflow event. Then, add _Only when_ conditions on each event. On the first one, add the condition only when `index's selectedGroup's value is group1`, and have one workflow action within the event that sets the custom state to `group2`. Do a similar thing on the other two events to set the state to `group3` or `group4` based upon the state currently being `group2` or `group3`, respectively.

If your editor was open, I could have set it up for you in the time it took me to write this response. So, if what I have written isn’t clear, open your editor and I will configure what I have described.

Best…  
Mike

---

<div class="post-metadata">

**Author:** ![darren.james7518](https://avatars.discourse-cdn.com/v4/letter/d/a3d4f5/32.png) [@darren.james7518](https://forum.bubble.io/u/darren.james7518)\
**Post date:** [March 7, 2022, 9:45pm UTC](https://forum.bubble.io/t/navigation-issue-on-single-page-app/195013/3 "2022-03-07T21:45:34Z")

</div>

Hi Mike,

Thank you for your detailed reply … I tried to do it but didn’t quite get it working. If you have time I have made the editor open.

Note: I have put it all back to how it was but instead of showing a group with custom state ‘selectedGroup’, I’ve added URL parameters to show a group when ‘tab’ is ‘group’s name’.

---

<div class="post-metadata">

**Author:** ![koechamos51](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/koechamos51/32/145975_2.png) [@koechamos51](https://forum.bubble.io/u/koechamos51)\
**Post date:** [March 7, 2022, 9:58pm UTC](https://forum.bubble.io/t/navigation-issue-on-single-page-app/195013/4 "2022-03-07T21:58:07Z")

</div>

A simple working version.

> **[Bubble - Visual Programming](https://navigation0703202.bubbleapps.io/version-test/index-copy-help?debug_mode=true)**
>
> Build stuff without code and launch a startup without a tech-cofounder! Bubble is a visual programing language. Instead of typing code, use a visual editor to build applications.

---

<div class="post-metadata">

**Author:** ![darren.james7518](https://avatars.discourse-cdn.com/v4/letter/d/a3d4f5/32.png) [@darren.james7518](https://forum.bubble.io/u/darren.james7518)\
**Post date:** [March 7, 2022, 10:23pm UTC](https://forum.bubble.io/t/navigation-issue-on-single-page-app/195013/6 "2022-03-07T22:23:14Z")

</div>

@koechamos51 It works perfectly but could you make the editor viewable because I can’t see how you achieved it?

---

<div class="post-metadata">

**Author:** ![mikeloc](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mikeloc/32/93001_2.png) [@mikeloc](https://forum.bubble.io/u/mikeloc)\
**Post date:** [March 7, 2022, 10:26pm UTC](https://forum.bubble.io/t/navigation-issue-on-single-page-app/195013/7 "2022-03-07T22:26:53Z")

</div>

They set it up on a separate page in your app, and it simply increments a custom state’s number by 1 with each click… definitely does the trick.

> **[Bubble Editor - Navigation0703202](https://bubble.io/page?type=page&name=index-copy-help&id=navigation0703202&tab=tabs-1)**
>
> Build stuff without code and launch a startup without a tech-cofounder! Bubble is a visual programing language. Instead of typing code, use a visual editor to build applications.

---

<div class="post-metadata">

**Author:** ![darren.james7518](https://avatars.discourse-cdn.com/v4/letter/d/a3d4f5/32.png) [@darren.james7518](https://forum.bubble.io/u/darren.james7518)\
**Post date:** [March 7, 2022, 10:31pm UTC](https://forum.bubble.io/t/navigation-issue-on-single-page-app/195013/8 "2022-03-07T22:31:51Z")

</div>

> [@mikeloc](#):
>
> They set it up on a separate page in your app, and it simply increments a custom state’s number by 1 with each click… definitely does the trick.

Thanks for pointing that out.

This does work and is very clean in the workflow but it means I can’t name the pages which I kind of wanted to do whilst making use of the URL parameters. I should have said that where I names a group ‘group2’ for example, that may be named ‘my-customers’ or something. I only used the ‘group1, 2, 3’ for simplicity for this post.

---

<div class="post-metadata">

**Author:** ![darren.james7518](https://avatars.discourse-cdn.com/v4/letter/d/a3d4f5/32.png) [@darren.james7518](https://forum.bubble.io/u/darren.james7518)\
**Post date:** [March 7, 2022, 10:40pm UTC](https://forum.bubble.io/t/navigation-issue-on-single-page-app/195013/9 "2022-03-07T22:40:52Z")

</div>

I can reproduce it using the selectedGroup custom state but not if I want to use the Get from URL state.

This works:

![1](https://us1.discourse-cdn.com/bubble/original/3X/f/d/fdb5b37bc635a8fabc2e7da6f4871286a27dee5e.png)

This doesn’t work:

 ![2](https://us1.discourse-cdn.com/bubble/original/3X/a/d/ad566f36620acbdb9eb86b215f2ac31c8237f83d.png)

---

<div class="post-metadata">

**Author:** ![darren.james7518](https://avatars.discourse-cdn.com/v4/letter/d/a3d4f5/32.png) [@darren.james7518](https://forum.bubble.io/u/darren.james7518)\
**Post date:** [March 7, 2022, 10:59pm UTC](https://forum.bubble.io/t/navigation-issue-on-single-page-app/195013/10 "2022-03-07T22:59:27Z")

</div>

> [@koechamos51](#):
>
> A simple working version.

You made use of the ‘selectedGroup +1’ function but do you know if it’s possible to do this using page URL parameters? Each of my groups are shown using page URL parameters so I wanted to avoid using the selectedGroup custom state.

I have an idea, the URL could be a page name but I could have an additional custom state of ‘group number’ and maybe let the navigation reference that.  
_No this doesn’t work._

---

<div class="post-metadata">

**Author:** ![mikeloc](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mikeloc/32/93001_2.png) [@mikeloc](https://forum.bubble.io/u/mikeloc)\
**Post date:** [March 7, 2022, 11:20pm UTC](https://forum.bubble.io/t/navigation-issue-on-single-page-app/195013/11 "2022-03-07T23:20:44Z")

</div>

Here is an example using a URL parameter.

> **[Bubble Editor - Navigation0703202](https://bubble.io/page?type=page&name=url-params&id=navigation0703202&tab=tabs-1)**
>
> Build stuff without code and launch a startup without a tech-cofounder! Bubble is a visual programing language. Instead of typing code, use a visual editor to build applications.

---

<div class="post-metadata">

**Author:** ![darren.james7518](https://avatars.discourse-cdn.com/v4/letter/d/a3d4f5/32.png) [@darren.james7518](https://forum.bubble.io/u/darren.james7518)\
**Post date:** [March 7, 2022, 11:26pm UTC](https://forum.bubble.io/t/navigation-issue-on-single-page-app/195013/12 "2022-03-07T23:26:57Z")

</div>

> [@mikeloc](#):
>
> Here is an example using a URL parameter.

That’s brilliant, thank you! I think I have plenty to work with now 🙂

Thanks @koechamos51 and @mikeloc for helping out!
