Skip to content

Commit b2849a2

Browse files
authored
fix: UTC-325: By Media Start Time sort doesn't work with Video Object Tracking template (#8682)
Co-authored-by: nass600 <nass600@users.noreply.github.com>
1 parent b7ee1f8 commit b2849a2

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

web/libs/editor/src/components/SidePanels/OutlinerPanel/ViewControls.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ interface ViewControlsProps {
4040

4141
const mediaStartTimeSupportedTags = [
4242
["labels", "audio"],
43+
["labels", "videorectangle", "video"],
4344
["timelinelabels", "video"],
4445
["timeserieslabels", "timeseries"],
4546
];

web/libs/editor/src/components/SidePanels/OutlinerPanel/__tests__/OutlinerPanel.test.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,34 @@ describe("OutlinerPanel", () => {
331331
expect(viewControls).toHaveAttribute("ordering", "mediaStartTime");
332332
});
333333

334+
it("supports mediaStartTime sorting option when labels, videorectangle and video tags are in config", () => {
335+
const regionsWithVideoRectangleConfig = {
336+
...mockRegions,
337+
sort: "mediaStartTime",
338+
annotation: {
339+
names: new Map([
340+
["myLabels", { name: "myLabels", type: "labels" }],
341+
["myVideoRectangle", { name: "myVideoRectangle", type: "videorectangle" }],
342+
["myVideo", { name: "myVideo", type: "video" }],
343+
]),
344+
},
345+
regions: [
346+
{ id: "1", type: "videorectangleregion", sequence: [{ frame: 30, enabled: true, x: 10, y: 10 }] },
347+
{ id: "2", type: "videorectangleregion", sequence: [{ frame: 10, enabled: true, x: 20, y: 20 }] },
348+
],
349+
filter: [
350+
{ id: "1", type: "videorectangleregion", sequence: [{ frame: 30, enabled: true, x: 10, y: 10 }] },
351+
{ id: "2", type: "videorectangleregion", sequence: [{ frame: 10, enabled: true, x: 20, y: 20 }] },
352+
],
353+
};
354+
355+
render(<OutlinerPanel {...defaultProps} regions={regionsWithVideoRectangleConfig} />);
356+
357+
const viewControls = screen.getByTestId("view-controls");
358+
expect(viewControls).toBeInTheDocument();
359+
expect(viewControls).toHaveAttribute("ordering", "mediaStartTime");
360+
});
361+
334362
it("does not support mediaStartTime when only labels tag is in config", () => {
335363
const regionsWithoutMediaConfig = {
336364
...mockRegions,

web/libs/editor/src/stores/RegionStore.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,13 @@ export default types
272272
}
273273

274274
// Handle timeline regions (video) - they have ranges with start frame
275-
if (region.type === "timelineregion" && region.ranges && region.ranges.length > 0) {
276-
// Get the first range's start frame
277-
const firstRange = region.ranges[0];
278-
if (firstRange && typeof firstRange.start === "number") {
279-
return firstRange.start;
280-
}
275+
if (region.type === "timelineregion" && region.ranges?.[0]) {
276+
return region.ranges[0].start;
277+
}
278+
279+
// Handle video rectangle regions - they have sequence with frames
280+
if (region.type === "videorectangleregion" && region.sequence?.[0]) {
281+
return region.sequence[0].frame;
281282
}
282283

283284
// Return null for regions without media time information

0 commit comments

Comments
 (0)