Skip to content

Commit

Permalink
fix(example): make sure selection change uses the entity binding comp…
Browse files Browse the repository at this point in the history
…onent index
  • Loading branch information
haweston committed Feb 2, 2024
1 parent eec0f50 commit 200d0db
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions examples/react-app/src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,15 @@ const ScenePage = () => {

const onSelectionChanged = useCallback(
(e: any) => {
if (e.additionalComponentData && e.additionalComponentData[0]?.dataBindingContext?.entityId) {
const entityId = e.additionalComponentData[0].dataBindingContext.entityId;
if (e.additionalComponentData && e.componentTypes) {
let entityId = selectedEntityId;
const entityIndex = e.componentTypes.findIndex((component: string) => component === 'EntityBinding')
const tagIndex = e.componentTypes.findIndex((component: string) => component === 'Tag')
if (e.additionalComponentData[entityIndex]?.dataBindingContext?.entityId) {
entityId = e.additionalComponentData[entityIndex].dataBindingContext.entityId;
} else if (e.additionalComponentData[tagIndex]?.dataBindingContext?.entityId) {
entityId = e.additionalComponentData[tagIndex].dataBindingContext.entityId;
}
if (selectedEntityId !== entityId) {
const query: IQueryData = { entityId: entityId };
setSelectedEntityId(entityId);
Expand Down

0 comments on commit 200d0db

Please sign in to comment.