Skip to content

Commit

Permalink
Allow deselection of selected items
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Boberg <[email protected]>
  • Loading branch information
axelboberg committed Mar 31, 2024
1 parent 7609766 commit 35794fc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions api/browser/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ function subtractSelection (item) {
* @param { String } item The id of an item to check
* @returns { Boolean }
*/
function isSelected (item) {
async function isSelected (item) {
assertIdentity()
const selection = state.getLocalState()?._connections?.[getIdentity()]?.selection
const selection = await state.get(`_connections.${getIdentity()}.selection`)
if (!selection) {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ Add one or more items to the selecton by their ids.
**Only available within the render process**
Subtract one or more items to the selecton by their ids.

### `bridge.client.isSelected(itemId): Boolean`
### `bridge.client.isSelected(itemId): Promise<Boolean>`
**Only available within the render process**
Check whether or not an item is selected by the current client.

Expand Down
20 changes: 16 additions & 4 deletions plugins/rundown/app/components/RundownList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,24 @@ export function RundownList ({
bridge.commands.executeCommand('rundown.moveItem', rundownId, newIndex, itemId)
}

function handleFocus (itemId) {
async function handleFocus (itemId) {
if (keyboard.keyIsPressed('meta')) {
bridge.client.addSelection(itemId)
} else {
bridge.client.setSelection(itemId)
const isSelected = await bridge.client.isSelected(itemId)
if (isSelected) {
bridge.client.subtractSelection(itemId)
} else {
bridge.client.addSelection(itemId)
}
return
}

if (keyboard.keyIsPressed('shift')) {
// Select all items between the last selection and the new item
// Check data-item-id
return
}

bridge.client.setSelection(itemId)
}

function handleFocusPropagation (e) {
Expand Down

0 comments on commit 35794fc

Please sign in to comment.