Skip to content

Commit

Permalink
feat(component-authoring): focus on component editing component when …
Browse files Browse the repository at this point in the history
…rendered

Focus causes browser to scroll element into view if necessary.
  • Loading branch information
breity committed Dec 11, 2024
1 parent c897fc6 commit dc24a18
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { components } from '../../../components/Components';
@Component({
selector: 'edit-component',
standalone: true,
template: '<div #component></div>'
template: '<div #component tabindex="-1"></div>'
})
export class EditComponentComponent {
@Input() componentContent: ComponentContent;
Expand All @@ -28,15 +28,17 @@ export class EditComponentComponent {
) {}

ngAfterViewInit(): void {
const hostElement = this.componentElementRef.nativeElement;
this.componentRef = createComponent(components[this.componentContent.type].authoring, {
hostElement: this.componentElementRef.nativeElement,
hostElement: hostElement,
environmentInjector: this.injector
});
Object.assign(this.componentRef.instance, {
componentContent: this.componentContent,
nodeId: this.nodeId
});
this.applicationRef.attachView(this.componentRef.hostView);
setTimeout(() => hostElement.focus());
}

ngOnDestroy(): void {
Expand Down

0 comments on commit dc24a18

Please sign in to comment.