-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Remove root level flags used to track cell selection and focus #9882
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
Remove root level flags used to track cell selection and focus #9882
Conversation
Codecov Report
@@ Coverage Diff @@
## ds/custom_editor #9882 +/- ##
===================================================
Coverage ? 60.62%
===================================================
Files ? 555
Lines ? 29737
Branches ? 4482
===================================================
Hits ? 18027
Misses ? 10709
Partials ? 1001
Continue to review full report at Codecov.
|
const info: { selectedCellId?: string; selectedCellIndex?: number; focusedCellId?: string; focusedCellIndex?: number } = {}; | ||
for (let index = 0; index < state.cellVMs.length; index += 1) { | ||
const cell = state.cellVMs[index]; | ||
if (cell.selected) { |
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.
Focus turns on selected as well. And they should never be different so you could simplify this a bit (no need to check for focuses after finding selected, just check if that cell is also focused). NBD if you don't want to change since this doesn't matter much.
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.
I agree, however I'd prefer if we had a single bitwise or enum flag instead.
Right now having two flags indicates they are mutually exclusive. This could lead to funky code.
I'd prefer to do that as a separate PR.
Focus turns on selected as well
Though the styles are different in the cell, e.g. when a code cell has focus, the style is not that of a selected cell (not blue) but the striped green.
Kudos, SonarCloud Quality Gate passed!
|
For #9340
To be merged after #9840
Basically I got rid of the root level state info that keeps track of the cell that's selected and focused.
This required us to keep the two in sync along with the state at the cell level.
When syncing information between multiple editors this got messy. removing this removes the issues where things could go out of sync, i.e. two ways to storing the same thing. Now we get selected information from the cells directly - single source of truth.