Skip to content

Commit

Permalink
Merge pull request Hubs-Foundation#6393 from mozilla/bitecs-media-lin…
Browse files Browse the repository at this point in the history
…k-hold-bug

Look for the holdable media root when grabbing an object
  • Loading branch information
keianhzo authored Dec 4, 2023
2 parents 8895b7b + b746f90 commit 13d7597
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/systems/hold-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import {
HeldHandLeft,
AEntity,
Networked,
MediaContentBounds
MediaLoader,
Deletable
} from "../bit-components";
import { canMove } from "../utils/permissions-utils";
import { canMove as canMoveEntity } from "../utils/bit-permissions-utils";
import { isPinned } from "../bit-systems/networking";
import { takeOwnership } from "../utils/take-ownership";
import { findAncestorWithComponent } from "../utils/bit-utils";
import { findAncestorWithComponents } from "../utils/bit-utils";

const GRAB_REMOTE_RIGHT = paths.actions.cursor.right.grab;
const DROP_REMOTE_RIGHT = paths.actions.cursor.right.drop;
Expand Down Expand Up @@ -78,7 +79,7 @@ function grab(world, userinput, queryHovered, held, grabPath) {
const hovered = queryHovered(world)[0];

// Special path for Dropped/Pasted Media with new loader enabled. Check the comment above.
const mediaRoot = findAncestorWithComponent(world, MediaContentBounds, hovered);
const mediaRoot = findAncestorWithComponents(world, [Deletable, MediaLoader, Holdable], hovered);
const target = mediaRoot ? mediaRoot : hovered;
const isEntityPinned = isPinned(target) || isAEntityPinned(world, target);

Expand Down
10 changes: 9 additions & 1 deletion src/utils/load-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,13 @@ export function* loadImage(world: HubsWorld, eid: EntityID, url: string, content

ObjectMenuTarget.flags[eid] |= ObjectMenuTargetFlags.Flat;

return renderAsEntity(world, <entity name="Image" image={imageDef} objectMenuTarget={{ isFlat: true }} />);
return renderAsEntity(
world,
<entity
name="Image"
image={imageDef}
objectMenuTarget={{ isFlat: true }}
grabbable={{ cursor: true, hand: false }}
/>
);
}

0 comments on commit 13d7597

Please sign in to comment.