fix: Fix DataDoc cell move down button #1410
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DataDoc cells have ⏫ ⏬ buttons to move them up or down in the DataDoc, but it's impossible to click on the ⏬ button because the next cell's ⏫ button always gets in the way.
Each cell has a header and a footer row of buttons, and the footer row overlaps the header row of the next cell. They are set to
opacity: 0
unless the cell is being hovered over, so you never see both at the same time. However, the issue is that elements on the page are automatically stacked bottom up, so that as you move down the page, each element stacks on top of earlier elements. Hovering doesn't care about order, so both the footer and the next header are both receiving the:hover
style at the same time, and the stacking order puts the header on top of the footer, so you can't click the ⏬ button.I fixed this issue by switching to
display: none
for just the header rows, which prevents them from receiving hover events. Then I moved the:hover
to the.data-doc-cell-container-pair
itself, instead of the button row. This means if you hover over a cell, the header/footers appear, and you can mouse over either without losing focus to nearby cells. Once you move past the headers and into another cell, the header/footer flips to the newly-hovered cell.I left the footer rows (and the first header) using
opacity: 0
to prevent layout shift: if both useddisplay: none
, the cells would move around as you hover. This could be solved by adding additional margin to the cells and negative margin to the header/footers, but this approach was easier.Here is a video of the change in action:
Screen.Recording.2024-02-14.at.2.40.52.PM.mov
Finally⸺the down logic in
moveCellAt()
was broken so I implemented the easiest fix, adjusting the index calculations. The actual issue is that the index is "wrong" for the footer buttons. You can see that in this screenshot, where I show the value of theindex
field next to the buttons:I assume that is intentional, and changing the
index
would require changes in all the other cell operations, so this seemed like the best fix.