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