@tantawowa/hosanna-ui 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist-manifest.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"artifact": "npm-sdk",
|
|
4
4
|
"packageName": "@tantawowa/hosanna-ui",
|
|
5
|
-
"version": "2.0.
|
|
6
|
-
"sourceCommit": "
|
|
5
|
+
"version": "2.0.2",
|
|
6
|
+
"sourceCommit": "811a31c682344d9aead9b495245eb6b479df33d5",
|
|
7
7
|
"files": [
|
|
8
8
|
{
|
|
9
9
|
"path": "LICENSE",
|
|
@@ -2619,7 +2619,7 @@
|
|
|
2619
2619
|
},
|
|
2620
2620
|
{
|
|
2621
2621
|
"path": "src/hosanna-ui/views/lib/BaseView.ts",
|
|
2622
|
-
"sha256": "
|
|
2622
|
+
"sha256": "ad210cb3e4b0483f32d3944a0be826aa099fd325ac087f46a6169663a5df371e"
|
|
2623
2623
|
},
|
|
2624
2624
|
{
|
|
2625
2625
|
"path": "src/hosanna-ui/views/lib/BuildConfig.ts",
|
package/package.json
CHANGED
|
@@ -214,6 +214,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
214
214
|
private boundViewModelHid = '';
|
|
215
215
|
private isApplyingViewModelFocus = false;
|
|
216
216
|
private lastReportedViewModelFocusId = '';
|
|
217
|
+
private pendingViewModelFocus = '';
|
|
217
218
|
|
|
218
219
|
//these parent child relationships refer to the view tree
|
|
219
220
|
parent?: IHosannaView<ViewState> = undefined;
|
|
@@ -811,6 +812,10 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
811
812
|
this.invalidateParentLayout();
|
|
812
813
|
this.notifyResize();
|
|
813
814
|
}
|
|
815
|
+
|
|
816
|
+
if (this.pendingViewModelFocus !== '') {
|
|
817
|
+
this.applyPendingViewModelFocus();
|
|
818
|
+
}
|
|
814
819
|
}
|
|
815
820
|
}
|
|
816
821
|
|
|
@@ -3352,9 +3357,52 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
3352
3357
|
return;
|
|
3353
3358
|
}
|
|
3354
3359
|
this.lastReportedViewModelFocusId = focusedId;
|
|
3360
|
+
// Focus moved for another reason, so a request still waiting for its target is out of date.
|
|
3361
|
+
this.pendingViewModelFocus = '';
|
|
3355
3362
|
vm.focused(focusedId);
|
|
3356
3363
|
}
|
|
3357
3364
|
|
|
3365
|
+
private isViewModelFocusTargetReady(target: string): boolean {
|
|
3366
|
+
const child = this.getViewById(target) as IHosannaView<ViewState> | undefined;
|
|
3367
|
+
return child !== undefined && child.canReceiveFocus === true && child.visible === true;
|
|
3368
|
+
}
|
|
3369
|
+
|
|
3370
|
+
/**
|
|
3371
|
+
* The model asked for a target before this view had rendered it, as when it
|
|
3372
|
+
* reveals a control and asks for focus on it in the same change. Called after
|
|
3373
|
+
* each render; applies the request once the target can take focus.
|
|
3374
|
+
*/
|
|
3375
|
+
private applyPendingViewModelFocus(): void {
|
|
3376
|
+
const target = this.pendingViewModelFocus;
|
|
3377
|
+
if (!this.viewModel || !this.isViewModelFocusTargetReady(target)) {
|
|
3378
|
+
return;
|
|
3379
|
+
}
|
|
3380
|
+
this.pendingViewModelFocus = '';
|
|
3381
|
+
if (this.isFocusOutsideThisView()) {
|
|
3382
|
+
// Focus left for another view while the request waited. Taking it back would steal it.
|
|
3383
|
+
return;
|
|
3384
|
+
}
|
|
3385
|
+
this.requestViewModelFocus(target);
|
|
3386
|
+
}
|
|
3387
|
+
|
|
3388
|
+
/**
|
|
3389
|
+
* True when another view, outside this one, holds focus. This view is only
|
|
3390
|
+
* told about focus changes beneath it, so a move to a sibling is found here.
|
|
3391
|
+
*/
|
|
3392
|
+
private isFocusOutsideThisView(): boolean {
|
|
3393
|
+
let view = this.focusManager.focusedView as IHosannaView<ViewState> | undefined;
|
|
3394
|
+
if (!view) {
|
|
3395
|
+
return false;
|
|
3396
|
+
}
|
|
3397
|
+
while (view) {
|
|
3398
|
+
if (view._hid === this._hid) {
|
|
3399
|
+
return false;
|
|
3400
|
+
}
|
|
3401
|
+
view = view.parent as IHosannaView<ViewState> | undefined;
|
|
3402
|
+
}
|
|
3403
|
+
return true;
|
|
3404
|
+
}
|
|
3405
|
+
|
|
3358
3406
|
private getFocusedViewId(): string {
|
|
3359
3407
|
const focusedView = this.focusManager.focusedView as IHosannaView<ViewState> | undefined;
|
|
3360
3408
|
return focusedView?.id ?? '';
|
|
@@ -3376,8 +3424,14 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
3376
3424
|
if (!current) {
|
|
3377
3425
|
return;
|
|
3378
3426
|
}
|
|
3379
|
-
if (field === 'focus'
|
|
3380
|
-
this.
|
|
3427
|
+
if (field === 'focus') {
|
|
3428
|
+
// A target that this view has not rendered yet is asked for again once it has.
|
|
3429
|
+
// An empty target means none, which also withdraws a request still waiting.
|
|
3430
|
+
const target = current.focus;
|
|
3431
|
+
this.pendingViewModelFocus = target === '' || this.isViewModelFocusTargetReady(target) ? '' : target;
|
|
3432
|
+
if (target !== '') {
|
|
3433
|
+
this.requestViewModelFocus(target);
|
|
3434
|
+
}
|
|
3381
3435
|
}
|
|
3382
3436
|
if (this.onViewModelChanged(field)) {
|
|
3383
3437
|
this.makeDirty('viewModel');
|
|
@@ -3402,6 +3456,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
3402
3456
|
this.hasStartedViewModel = false;
|
|
3403
3457
|
this.boundViewModelHid = '';
|
|
3404
3458
|
this.lastReportedViewModelFocusId = '';
|
|
3459
|
+
this.pendingViewModelFocus = '';
|
|
3405
3460
|
this.bindViewModel();
|
|
3406
3461
|
}
|
|
3407
3462
|
|
|
@@ -3414,6 +3469,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
3414
3469
|
vm.removeObservers(this);
|
|
3415
3470
|
this.boundViewModelHid = '';
|
|
3416
3471
|
this.lastReportedViewModelFocusId = '';
|
|
3472
|
+
this.pendingViewModelFocus = '';
|
|
3417
3473
|
if (!this.disposesViewModelOnUnmount) {
|
|
3418
3474
|
if (this.hasStartedViewModel) {
|
|
3419
3475
|
vm.suspend();
|
|
@@ -3442,6 +3498,7 @@ export class BaseView<T extends ViewState, R extends ISGNGroup = ISGNGroup> impl
|
|
|
3442
3498
|
this.hasStartedViewModel = false;
|
|
3443
3499
|
this.boundViewModelHid = '';
|
|
3444
3500
|
this.lastReportedViewModelFocusId = '';
|
|
3501
|
+
this.pendingViewModelFocus = '';
|
|
3445
3502
|
}
|
|
3446
3503
|
|
|
3447
3504
|
/** Assignment to an `@observable` field: observe the new object, then store it. */
|