The first page select in dynamic navigation is loaded every time the app is run

I’m building app locally and building the following structure to navigate between the pages to enter in a select page and then choose a report.
Main Page → Select Report Page.

I read and was following the instructions in the following page of streamlit:

Every time a choose the Report page , the Main page is loaded

Main Page Code:

import streamlit as st

about_page = st.Page(
“pages/home.py”,
title="Home Page ",
default=True,

)
project_1_page = st.Page(
“pages/report_type1.py”,
title=“Report Type 1”,

)

pg = st.navigation(
{
“Home”: [about_page],
“Report Page”: [project_1_page, ],
}
)
Select Report Page code:

import streamlit as st

if “role” not in st.session_state:
st.session_state.role = None

ROLES = [“Bonds”, “FX”]

def select():
st.header(“Log in”)
role = st.selectbox(“Choose your role”, ROLES)
if st.button(“Log in”):
st.session_state.role = role
st.rerun()

role = st.session_state.role
page_bonds = st.Page(
“pages/Report_type/ch_bonds.py”,
default=(role == “Bonds”)
)
page_fx = st.Page(
“pages/Report_type/ch_fx.py”,
default= True)

request_pages = [page_bonds, page_fx]

page_dict = {}

if st.session_state.role in [“Bonds”]:
page_dict[“Bonds”] = request_pages
if st.session_state.role in [“FX”]:
page_dict[“FX”] = request_pages

if len(page_dict) > 0:
pg = st.navigation(page_dict)
else:
pg = st.navigation([st.Page(select)])
pg.run()

pg.run()

Hi @thsantos1911, welcome to the forum! Can you please re-post your code as a code block, so that it’s possible to see it with indentation?