Skip to content

Commit

Permalink
Fix an issue where each group would register its own listeners for sh…
Browse files Browse the repository at this point in the history
…ortcuts

Signed-off-by: Axel Boberg <[email protected]>
  • Loading branch information
axelboberg committed Feb 29, 2024
1 parent ba6023d commit 3189105
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugins/rundown/app/components/RundownGroupItem/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export function RundownGroupItem ({ index, item }) {
onDrop={e => handleDrop(e)}
/>
)
: <RundownList className='RundownGroupItem-children' rundownId={item.id} indexPrefix={`${index}.`} />
: <RundownList className='RundownGroupItem-children' rundownId={item.id} indexPrefix={`${index}.`} disableShortcuts />
}
</div>
</div>
Expand Down
13 changes: 10 additions & 3 deletions plugins/rundown/app/components/RundownList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ async function toggleDisableSelection () {
export function RundownList ({
rundownId = '',
className = '',
indexPrefix = ''
indexPrefix = '',
disableShortcuts = false
}) {
const [shared] = React.useContext(SharedContext)

Expand Down Expand Up @@ -169,11 +170,13 @@ export function RundownList ({
* from the current selection
* @param { Number } deltaIndex
*/
function select (deltaIndex = 0) {
async function select (deltaIndex = 0) {
if (itemIds.length === 0) {
return
}

const selection = await bridge.client.getSelection()

/*
Find the currently selected item id,
use the first selected item if going upwards
Expand Down Expand Up @@ -245,11 +248,15 @@ export function RundownList ({
}
}

if (disableShortcuts) {
return
}

bridge.events.on('shortcut', onShortcut)
return () => {
bridge.events.off('shortcut', onShortcut)
}
}, [itemIds, selection])
}, [itemIds, rundownId, disableShortcuts])

/*
Try to scroll to the selection
Expand Down

0 comments on commit 3189105

Please sign in to comment.