Skip to content

Commit 1b0c3c8

Browse files
committed
Places: Keep scrollbar hidden when opening the cluster view #3168
Signed-off-by: Michael Mayer <michael@photoprism.app>
1 parent 834c16b commit 1b0c3c8

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

frontend/src/common/view.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ export class View {
221221
constructor() {
222222
this.uid = 0;
223223
this.scopes = [];
224+
this.hideScrollbar = false;
224225
this.preventNavigation = false;
225226

226227
if (trace) {
@@ -317,7 +318,7 @@ export class View {
317318
return;
318319
}
319320

320-
let hideScrollbar = false;
321+
let hideScrollbar = this.layers() > 2 ? this.hideScrollbar : false;
321322
let disableScrolling = false;
322323
let disableNavigationGestures = false;
323324
let preventNavigation = uid > 0 && !name.startsWith("PPage");
@@ -351,6 +352,7 @@ export class View {
351352
break;
352353
}
353354

355+
this.hideScrollbar = hideScrollbar;
354356
this.preventNavigation = preventNavigation;
355357

356358
const htmlEl = getHtmlElement();
@@ -429,6 +431,11 @@ export class View {
429431
return true;
430432
}
431433

434+
// Returns the current number of view layers.
435+
layers() {
436+
return this.scopes?.length ? this.scopes.length : 0;
437+
}
438+
432439
// Returns the currently active view component or null if none exists.
433440
current() {
434441
if (this.scopes.length) {
@@ -438,6 +445,26 @@ export class View {
438445
}
439446
}
440447

448+
// Returns the parent view of the currently active view or null if none exists.
449+
parent() {
450+
if (this.scopes.length > 1) {
451+
return this.scopes[this.scopes.length - 2];
452+
} else {
453+
return null;
454+
}
455+
}
456+
457+
// Returns the name of the parent view component or an empty string if none exists.
458+
parentName() {
459+
const c = this.parent();
460+
461+
if (!c) {
462+
return "";
463+
}
464+
465+
return c?.$options?.name ? c.$options.name : "";
466+
}
467+
441468
// Returns the currently active view data or an empty reactive object otherwise.
442469
data() {
443470
const c = this.current();
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { $view } from "common/view";
2+
3+
let chai = require("chai/chai");
4+
let assert = chai.assert;
5+
6+
describe("common/view", () => {
7+
it("should return parent", () => {
8+
assert.equal($view.parent(), null);
9+
});
10+
it("should return parent name", () => {
11+
assert.equal($view.parentName(), "");
12+
});
13+
it("should return data", () => {
14+
assert.containsSubset($view.data(), {});
15+
});
16+
it("should return number of layers", () => {
17+
assert.containsSubset($view.layers(), 0);
18+
});
19+
it("should return if root view is active", () => {
20+
assert.equal($view.isRoot(), true);
21+
});
22+
it("should return if view is app", () => {
23+
assert.equal($view.isApp(), true);
24+
});
25+
});

0 commit comments

Comments
 (0)