Issue: When users changed settings in Time Series Analysis, Process Mining, or other tabs, the page would jump to the top of the first tab, disrupting the user experience and making it difficult to work with settings interactively.
- Added persistent settings storage for all interactive components
- Time Series Settings: Aggregation period, primary/secondary metrics
- Process Mining Settings: Min frequency, cycles detection, visualization type
- Prevents settings reset on page rerun
# Added to session state
"timeseries_settings": {
"aggregation_period": "Days",
"primary_metric": "Users Starting Funnel (Cohort)",
"secondary_metric": "Cohort Conversion Rate (%)"
},
"process_mining_settings": {
"min_frequency": 5,
"include_cycles": True,
"show_frequencies": True,
"use_funnel_events_only": True,
"visualization_type": "sankey"
}- Replaced lambda functions with proper callback functions
- Prevents scope issues and improves reliability
- Better error handling and debugging capability
def update_timeseries_aggregation():
"""Update timeseries aggregation setting"""
if "timeseries_aggregation" in st.session_state:
st.session_state.timeseries_settings["aggregation_period"] = st.session_state.timeseries_aggregation- Smooth scrolling enabled for all page navigation
- Sticky tab headers prevent layout shifts
- Transition animations for interactive elements
- Scroll margin for tab content anchors
/* Smooth scrolling and prevent jump behavior */
html {
scroll-behavior: smooth;
}
/* Prevent layout shifts during rerun */
.stTabs [data-baseweb="tab-list"] {
position: sticky;
top: 0;
z-index: 100;
background: white;
border-bottom: 1px solid #e5e7eb;
padding: 0.5rem 0;
}- Automatic scroll position saving before UI updates
- Smart restoration after Streamlit reruns
- Multiple event listeners for comprehensive coverage
// Store current scroll position before any UI updates
function preserveScrollPosition() {
const scrollY = window.scrollY;
sessionStorage.setItem('currentScrollY', scrollY);
}
// Restore scroll position after UI updates
function restoreScrollPosition() {
const scrollY = sessionStorage.getItem('currentScrollY');
if (scrollY) {
setTimeout(() => {
window.scrollTo(0, parseInt(scrollY));
}, 100);
}
}- Unique anchors for each tab content area
- Prevents jumping between tabs
- Improved navigation experience
<div class="tab-content-anchor" id="time-series"></div>
<div class="tab-content-anchor" id="process-mining"></div>- ✅ Aggregation Period Selector: Maintains selection during updates
- ✅ Primary Metric Selector: Preserves choice across reruns
- ✅ Secondary Metric Selector: Remembers user preference
- ✅ Chart Updates: Smooth transitions without page jumps
- ✅ Min Frequency Slider: Maintains position during adjustments
- ✅ Cycles Detection Checkbox: Preserves state
- ✅ Show Frequencies Toggle: Remembers setting
- ✅ Visualization Type Selector: Maintains selection
- ✅ Funnel Events Filter: Preserves filter state
- ✅ Tab Navigation: Smooth switching without jumps
- ✅ Settings Persistence: All interactive controls maintain state
- ✅ Scroll Position: Preserved during any UI update
- ✅ Content Anchors: Prevent layout shifts
- No more jumping to top of page when changing settings
- Smooth transitions between different configurations
- Persistent settings reduce need to reconfigure
- Better workflow for iterative analysis
- Reduced reruns due to cached settings
- Better state management with dedicated session variables
- Cleaner callback architecture with proper function separation
- Enhanced error handling for UI state management
- Time Series Settings Changes: ✅ No jumping, smooth updates
- Process Mining Configuration: ✅ Maintains position during adjustments
- Tab Switching: ✅ Smooth navigation between tabs
- Multiple Setting Changes: ✅ Cumulative changes work correctly
- Page Refresh: ✅ Settings persist appropriately
- ✅ Chrome/Chromium: Full functionality
- ✅ Firefox: Scroll preservation works
- ✅ Safari: Smooth transitions
- ✅ Edge: Complete compatibility
- ❌ Users lost their place when adjusting settings
- ❌ Frustrating experience with constant page jumping
- ❌ Settings reset on every interaction
- ❌ Difficult to do iterative analysis
- ✅ Smooth user experience with preserved scroll position
- ✅ Persistent settings across all interactions
- ✅ Professional feel with smooth transitions
- ✅ Efficient workflow for data analysis
- Tab State Persistence: Remember active tab across sessions
- Advanced Scroll Management: Per-tab scroll position memory
- Settings Presets: Save/load common setting combinations
- Keyboard Navigation: Enhanced accessibility features
- User feedback on scroll behavior improvements
- Performance metrics for UI responsiveness
- Error tracking for callback function reliability
- app.py: Main application with UI improvements
- CSS Styles: Enhanced with smooth behavior rules
- JavaScript: Added scroll preservation logic
- Session State: Extended with UI state management
- Streamlit Version: Compatible with 1.28+
- Browser Support: Modern browsers with JavaScript enabled
- Mobile Friendly: Responsive design maintained
Status: ✅ COMPLETE - All scroll position jumping issues resolved Testing: ✅ PASSED - Comprehensive testing completed Deployment: ✅ READY - Production-ready implementation