Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better double click on item in scene graph #855

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/editor/components/scenegraph/Entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,20 @@ export default class Entity extends React.Component {
});

return (
<div className={className} onClick={this.onClick} id={this.props.id}>
<div
className={className}
onClick={this.onClick}
onDoubleClick={this.onDoubleClick}
id={this.props.id}
>
<span>
<span
style={{
width: `${30 * (this.props.depth - 1)}px`
}}
/>
{visibilityButton}
{printEntity(entity, this.onDoubleClick)}
{printEntity(entity)}
{collapse}
</span>
<span className="entityActions">
Expand Down
6 changes: 4 additions & 2 deletions src/editor/components/scenegraph/SceneGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ export default class SceneGraph extends React.Component {
for (let i = 0; i < this.state.entities.length; i++) {
const entityOption = this.state.entities[i];
if (entityOption.entity === entity) {
this.setState({ selectedIndex: i }, () => {
this.setState({ selectedIndex: i });
setTimeout(() => {
// wait 500ms to allow user to double click on entity
document
.getElementById('sgnode' + i)
?.scrollIntoView({ behavior: 'smooth' });
});
}, 500);
// Make sure selected value is visible in scenegraph
this.expandToRoot(entity);
posthog.capture('entity_selected', {
Expand Down
4 changes: 2 additions & 2 deletions src/editor/lib/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ const ICONS = {
light: 'fa-lightbulb-o',
text: 'fa-font'
};
export function printEntity(entity, onDoubleClick) {
export function printEntity(entity) {
if (!entity) {
return '';
}
Expand All @@ -589,7 +589,7 @@ export function printEntity(entity, onDoubleClick) {
// Custom display name for a layer if available, otherwise use entity name or tag
let displayName = getEntityDisplayName(entity);
return (
<span className="entityPrint" onDoubleClick={onDoubleClick}>
<span className="entityPrint">
{displayName && <span className="entityName">&nbsp;{displayName}</span>}
{!!icons && (
<span
Expand Down