housekeeping updates #7
2 changed files with 15 additions and 2 deletions
|
@ -1,14 +1,21 @@
|
|||
@inject IJSRuntime JSRuntime
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public Func<ElementReference> GetControl { get; set; }
|
||||
public Func<ElementReference>? GetControl { get; set; }
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (GetControl is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(GetControl));
|
||||
}
|
||||
|
||||
if (firstRender)
|
||||
{
|
||||
await JSRuntime.InvokeVoidAsync("App.scrollIntoView", GetControl(), true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +1,15 @@
|
|||
var App = App || {};
|
||||
const App = App || {};
|
||||
|
||||
App.setFocus = function (element) {
|
||||
element.focus();
|
||||
}
|
||||
|
||||
App.scrollIntoView = function (element, args) {
|
||||
if (element === undefined) {
|
||||
console.error('Element is undefined');
|
||||
} else if (element === null) {
|
||||
console.error('Element is null');
|
||||
}
|
||||
|
||||
element.scrollIntoView(args);
|
||||
}
|
Loading…
Reference in a new issue