from puepy import Application, Page, t
app = Application()
@app.page()
class HelloWorldPage(Page):
def initial(self):
return {"messages": []}
def populate(self):
t.h1("Test...")
for msg in self.state["messages"]:
t.p(msg)
t.sl_button("Click 1!", on_click=self.on_click_1)
t.sl_button("Click 2!", on_click=self.on_click_2)
t.sl_button("Click 3!", on_click=self.on_click_3)
def on_click_1(self, event):
with self.state.mutate("messages"):
self.state["messages"].append("You clicked button 1!")
def on_click_2(self, event):
with self.state.mutate("messages"):
self.state["messages"].append("You clicked button 2!")
def on_click_3(self, event):
with self.state.mutate("messages"):
self.state["messages"].append("You clicked button 3!")
app.mount("#app")
The first time you click on button 1, it shows the correct message. The next time, it thinks it's button 2. The next, button 3. Then it's always button3:
Consider this example:
The first time you click on button 1, it shows the correct message. The next time, it thinks it's button 2. The next, button 3. Then it's always button3:
https://github.com/kkinder/puepy/assets/1115018/4126fd44-1255-4e09-9ba4-278491c9f4bc
This only happens with Shoelace elements.