briefercloud / briefercloud/briefer

Dropdown with dynamic dataframe has selection issues when the data changes underneath

Open
#213 1 comment 0 reactions 0 assignees View on GitHub
bug discussion-needed
Dominant language
TypeScript
Stars
4.3k
Forks
290
PR merge metrics
No merged PRs in 30d

Description

### Setup

I have a static dict of test metadata which I currently update manually from time to time.
```
tests = {id_a: {...}, ..., id_n: {...}}.
tests_df = pd.DataFrame({"test_ids": tests.keys()})
```
I have a dynamic dropdown (`test_id`) using the above dataframe (`tests_df`).

I query the data based on the selected `test_id`.
The results contain among other things a date (`date_time`) for each entry.
I do some filtering and then I want to analyse a specific window of time. I do this by selecting a start `date_time` and a duration.
```
date_times_df = pd.DataFrame({"date_time": data['date_time'].astype(str)})
```
I here have a dynamic dropdown (`window_start`) using the above dataframe (`date_times_df`) and a text input for `window_duration`.

Using `window_start` and `window_duration` I then filter the original data to do some analysis.

### Issue

#### Live mode
When I change the `test_id` dropdown and Run all, the data and its dates change. But the `window_start` dropdown for some reason does not update its dynamic list of values.

#### Edit mode
When I change the `test_id` dropdown and Run onwards, the data and its dates change.
The `window_start` dropdown's values change but the previously selected value is not present in the new set. Sometimes this just results in no analysis (as the window is out of data bounds) but a lot of the times this results in a grayed out unselectable dropdown and I have to unset and reset the `date_times_df` as its dataframe to fix it.

### Possible solutions
One possible solution would be to provide a default value for the dropdown.
E.g. if the dropdown modifies the `window_start` variable, it would be nice to check if the value exists before and use it for the default selected value.
```
date_times_df = pd.DataFrame({"date_time": data['date_time'].astype(str)})
window_start = date_times_df[0]
```
Another possible solution would be to default to the first value of the dataframe.
Another possible solution would be to use the Date input method, but then again, I would want to limit the min and max dates that can be chosen.
I may be using this wrong and the solution is elsewhere. In this case I would be grateful if someone can point me in the right direction.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the reported behavior with a pandas DataFrame-backed dynamic dropdown in both Live mode and Edit mode, changing test_id so the available dates change. Trace the dropdown state and dataframe update entry points; done means the options refresh and an invalid previous selection is handled without a grayed-out control or manual reset.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter, pandas, python, typescript
Domain
data, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.