-
Notifications
You must be signed in to change notification settings - Fork 1
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
Track viewed tabs in TabWidget component #144
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few thoughts on the implementation of this. I agree it’s the right thing to do in general
@@ -15,6 +15,17 @@ const TabWidget: FunctionComponent<TabWidgetProps> = ({ labels, children }) => { | |||
} | |||
|
|||
const [index, setIndex] = useState(0); | |||
const [tabsThatHaveBeenViewed, setTabsThatHaveBeenViewed] = useState< | |||
number[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on using a boolean[] of the same length as labels, rather than a number[]?
@WardBrian I made all your suggested changes/simplifications, except for your changing the state type to boolean[]. I think it's cleaner as number[] because
|
An additional possibility would be to just use a But I don't really feel too strongly about this--I think it'll be easy enough to adapt the solution if we ever decide to support those features. |
Yeah, I'm happy with the current solution and the options we have for crossing-bridges-should-we-come-to-them |
Also note, re #142, it appears that while the tab stays mounted, as you observe with the splitters maintaining their states, the pyodide worker does seem to terminate still. I think there is a separate set of changes deeper in the call stack needed to fix that, but I'm also planning on proposing some refactors to those component's organization that I think would fix it anyway. So besides the one comment above I think this can be merged as-is |
Co-authored-by: Brian Ward <[email protected]>
This was discussed in #142
With this PR: In tab widget, tab content is not removed from DOM when switching between tabs, but also the tab content is not included in the DOM until the tab was viewed at least once. This involves keeping a state
tabsThatHaveBeenViewed
.To verify this is working:
Then for a second test: