Skip to content

Commit be31092

Browse files
committed
SOFIE-282 | fix scroll issues in properties editor
1 parent fccdc29 commit be31092

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

packages/webui/src/client/ui/RundownView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,7 @@ const RundownViewContent = translateWithTracker<IPropsWithReady & ITrackedProps,
13781378
<SelectedElementsContext.Consumer>
13791379
{(selectionContext) => {
13801380
const isPropertiesPanelOpen = selectionContext.listSelectedElements().length > 0
1381+
13811382
return (
13821383
<div
13831384
className={classNames('rundown-view', {

packages/webui/src/client/ui/RundownView/SelectedElementsContext.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { createContext, useCallback, useContext, useEffect, useMemo, useReducer, useState } from 'react'
1+
import React, { createContext, useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState } from 'react'
22
import {
33
AdLibActionId,
44
PartId,
@@ -215,12 +215,21 @@ export function useSelectedElements(
215215
const [segment, setSegment] = useState<DBSegment | undefined>(undefined)
216216
const rundownId = piece ? piece.startRundownId : part ? part.rundownId : segment?.rundownId
217217

218+
const lastValidPiece = useRef<Piece | undefined>(undefined)
219+
218220
useEffect(() => {
219221
clearPendingChange() // element id changed so any pending change is for an old element
220222

221223
const computation = Tracker.nonreactive(() =>
222224
Tracker.autorun(() => {
223-
const piece = Pieces.findOne(selectedElement?.elementId)
225+
let piece = Pieces.findOne(selectedElement?.elementId)
226+
227+
if (!piece && lastValidPiece.current && lastValidPiece.current._id === selectedElement?.elementId) {
228+
piece = lastValidPiece.current
229+
} else if (piece) {
230+
lastValidPiece.current = piece
231+
}
232+
224233
const part = UIParts.findOne({ _id: piece ? piece.startPartId : selectedElement?.elementId })
225234
const segment = Segments.findOne({ _id: part ? part.segmentId : selectedElement?.elementId })
226235

packages/webui/src/client/ui/SegmentTimeline/SourceLayerItem.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,14 @@ export const SourceLayerItem = (props: Readonly<ISourceLayerItemProps>): JSX.Ele
176176
innerPiece.userEditProperties?.globalProperties ||
177177
innerPiece.userEditProperties?.operations?.length
178178
)
179+
179180
if (!hasEditableContent) return
180181

181182
const pieceId = innerPiece._id
182-
if (!selectElementContext.isSelected(pieceId)) {
183-
RundownViewEventBus.emit(RundownViewEvents.CLOSE_NOTIFICATIONS)
184-
selectElementContext.clearAndSetSelection({ type: 'piece', elementId: pieceId })
185-
} else {
186-
selectElementContext.clearSelections()
187-
}
183+
184+
RundownViewEventBus.emit(RundownViewEvents.CLOSE_NOTIFICATIONS)
185+
selectElementContext.clearAndSetSelection({ type: 'piece', elementId: pieceId })
186+
188187
// Until a proper data structure, the only reference is a part.
189188
// const partId = this.props.part.instance.part._id
190189
// if (!selectElementContext.isSelected(partId)) {

packages/webui/src/client/ui/UserEditOperations/PropertiesPanel.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ export function PropertiesPanel(): JSX.Element {
4545
const pieceChangedId = selectedElement?.type === 'piece' && hadPiece && piece === undefined
4646

4747
if (pieceChangedId) {
48-
setHadPiece(false)
49-
clearSelections()
48+
console.log('clearing in hook')
49+
// setHadPiece(false)
50+
// clearSelections()
5051
}
5152
}, [selectedElement, piece, hadPiece, clearSelections])
5253

0 commit comments

Comments
 (0)