Skip to content

Commit

Permalink
fix context menu color setting: it used an outdated snapshot of focus…
Browse files Browse the repository at this point in the history
…ed items
  • Loading branch information
raimohanska committed Feb 18, 2021
1 parent 847bbc3 commit d5ceb9a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
3 changes: 2 additions & 1 deletion cypress/integration/basic.js
Expand Up @@ -281,6 +281,7 @@ describe("Board functionality", () => {
})

NotesWithText("HELLO").click({ force: true })
cy.get(".text").contains("HELLO").type("Monoids")
cy.get(".context-menu").scrollIntoView().should("be.visible")
cy.get(".colors")
.find(".color")
Expand All @@ -291,7 +292,7 @@ describe("Board functionality", () => {
const newColor = templateWithNewColor.style.background

templateWithNewColor.click()
NotesWithText("HELLO").then((els) => {
NotesWithText("Monoids").then((els) => {
expect(els[0].style.background, `Note 'HELLO' should have turned ${newColor}`).to.equal(newColor)
})
})
Expand Down
33 changes: 17 additions & 16 deletions frontend/src/board/ContextMenuView.tsx
Expand Up @@ -18,22 +18,23 @@ export const ContextMenuView = ({
board: L.Property<Board>
focus: L.Property<BoardFocus>
}) => {
const focusedItems = L.view(
focus,
(f) => {
switch (f.status) {
case "dragging":
return []
case "editing":
return [f.id]
case "none":
return []
case "selected":
return [...f.ids]
}
},
(ids) => ids.map(getItem(board.get())),
)
function itemIdsForContextMenu(f: BoardFocus) {
switch (f.status) {
case "dragging":
return []
case "editing":
return [f.id]
case "none":
return []
case "selected":
return [...f.ids]
}
}

const focusedItems = L.view(focus, board, (f, b) => {
const itemIds = itemIdsForContextMenu(f)
return itemIds.map(getItem(board.get()))
})

const focusItem = L.view(focusedItems, (items) => {
if (items.length === 0) return null
Expand Down

0 comments on commit d5ceb9a

Please sign in to comment.