Skip to content

Feature/reclickable button #672

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

clare-chemery
Copy link

@clare-chemery clare-chemery commented Apr 14, 2025


name: Feature/reclickable-button
about: For data exploration, you may want to refresh components that randomly sample data. Therefore the button should be reclickable and downstream components should update.
title: ''
labels: ''
assignees: ''

Description of Changes
The state management for components is currently based on the "value" key in their component definitions in preswald/interfaces/components.py. This means that once a button, for example, is True, it can no longer be reclicked. By adding a random state to the button when the reclick functionality is desired, a reclick will trigger a re-rendering of downstream components that have changed.

All components that already include the "value" key automatically re-render, but components without this key - e.g. image() and plotly() components - do not. I have added an optional "state_key" to the component dictionaries which can be used to point to the attribute which should control the state of the component on the frontend.

Finally, I added my app, lego-challenge which showcases the new reclickable button, leading to re-rendering of text, image, and plotly components downstream. Note: This PR also fixes a bug that I noticed with the slider in the tutorial: changing the value of the slider does not update the number of rows shown in the table.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • New example
  • Test improvement

Testing
Please describe the tests that you ran to verify your changes. Include screenshots/videos.

Run the lego-challenge app and click the "Take a step!" button multiple times to see the downstream components update.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have run my code against examples and ensured no errors
  • Any dependent changes have been merged and published in downstream modules

@clare-chemery clare-chemery marked this pull request as draft April 14, 2025 12:33
@clare-chemery clare-chemery marked this pull request as ready for review April 14, 2025 13:42
@clare-chemery
Copy link
Author

Hi @shivam-singhal @amrutha97 - when I was working on my demo app I noted that a reclickable button would be a "nice to have" feature for exploratory data apps. This PR implements the reclickable button and makes state management more explicit between the library and the frontend. Let me know what you think!

@amrutha97 amrutha97 force-pushed the main branch 2 times, most recently from 6ac1dad to bdb2c4e Compare April 24, 2025 07:54
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.

1 participant