From 6001799ac565e381cc095abc8ff4de8a7a04d13d Mon Sep 17 00:00:00 2001 From: devdudumuniz <82589615+devdudumuniz@users.noreply.github.com> Date: Sat, 29 Aug 2026 21:37:53 +0000 Subject: [PATCH] UX Enhancement: Disabled State for Selection Buttons * Change the `add_to_queue` button in `pysus/web/pages/1_client.py` to always render, but with `disabled=not selected_indices` instead of conditionally hiding it `if selected_indices and st.button(...)`. * Change the `remove` button in `pysus/web/pages/1_client.py` to always render, but with `disabled=not remove_indices` instead of conditionally hiding it `if remove_indices and st.button(...)`. * Change the `clear` button in `pysus/web/pages/1_client.py` to always render, but with `disabled=not download_queue`. * Change the `download` button in `pysus/web/pages/1_client.py` to always render, but with `disabled=not download_queue`. * This prevents layout shifts (buttons suddenly appearing/disappearing) and makes the UI actions more discoverable, providing a better user experience. --- .Jules/palette.md | 3 +++ pysus/web/pages/1_client.py | 21 ++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 .Jules/palette.md diff --git a/.Jules/palette.md b/.Jules/palette.md new file mode 100644 index 00000000..1551e3f6 --- /dev/null +++ b/.Jules/palette.md @@ -0,0 +1,3 @@ +## 2024-03-01 - Disabled states instead of conditional rendering +**Learning:** In Streamlit apps, hiding action buttons (like "Add to Queue", "Clear", "Download", "Remove") when there's no data or selection causes layout shifts and hurts discoverability. +**Action:** Always render the buttons but use `disabled=True` based on the data/selection state so users can see the available actions even if they can't perform them yet. diff --git a/pysus/web/pages/1_client.py b/pysus/web/pages/1_client.py index fd5cfdb5..73cd7699 100644 --- a/pysus/web/pages/1_client.py +++ b/pysus/web/pages/1_client.py @@ -812,8 +812,10 @@ def _show_results(pysus: PySUS, client: str) -> None: col1, col2 = st.columns([3, 1]) with col2: - if selected_indices and st.button( - t("add_to_queue", _lang()), width="stretch" + if st.button( + t("add_to_queue", _lang()), + width="stretch", + disabled=not selected_indices, ): new_indices = [ i for i in selected_indices if i not in queued_indices @@ -888,18 +890,27 @@ def _show_results(pysus: PySUS, client: str) -> None: st.rerun() col1, col2, col3 = st.columns(3) with col1: - if remove_indices and st.button(t("remove", _lang()), width="stretch"): + if st.button( + t("remove", _lang()), width="stretch", disabled=not remove_indices + ): remove_targets = {queued_indices[i] for i in remove_indices} st.session_state[queue_key] = [ i for i in queued_indices if i not in remove_targets ] st.rerun() with col2: - if st.button(t("clear", _lang()), width="stretch"): + if st.button( + t("clear", _lang()), width="stretch", disabled=not download_queue + ): st.session_state[queue_key] = [] st.rerun() with col3: - if st.button(t("download", _lang()), width="stretch", type="primary"): + if st.button( + t("download", _lang()), + width="stretch", + type="primary", + disabled=not download_queue, + ): _download_selected( pysus, client, download_queue, st.session_state[dir_key] )