From e00b890724c1a14515aba36a4b028c00792127e3 Mon Sep 17 00:00:00 2001 From: "David Richards, Jr" Date: Mon, 18 Mar 2024 16:48:03 -0400 Subject: [PATCH] fix(FocusManager): add patching of itemPosX and itemPosY to Items --- .../src/components/FocusManager/FocusManager.js | 14 ++++++++++++++ .../components/FocusManager/FocusManager.test.js | 1 + 2 files changed, 15 insertions(+) diff --git a/packages/@lightningjs/ui-components/src/components/FocusManager/FocusManager.js b/packages/@lightningjs/ui-components/src/components/FocusManager/FocusManager.js index a9fc4db8d..496117819 100644 --- a/packages/@lightningjs/ui-components/src/components/FocusManager/FocusManager.js +++ b/packages/@lightningjs/ui-components/src/components/FocusManager/FocusManager.js @@ -54,6 +54,20 @@ export default class FocusManager extends Base { this._checkSkipFocus(); } + _update() { + super._update(); + this._updateItemPos(); + } + + // I think this is necessary, because there is nothing other than _restItems patching in itemPosX and itemPosY, + // whereas the previous setters were setting the x and y values for Items. -David + _updateItemPos() { + this.Items.patch({ + x: this.itemPosX, + y: this.itemPosY + }); + } + get Items() { if (!this.tag('Items')) { this.patch({ Items: {} }); diff --git a/packages/@lightningjs/ui-components/src/components/FocusManager/FocusManager.test.js b/packages/@lightningjs/ui-components/src/components/FocusManager/FocusManager.test.js index 49099d79c..91bf020a3 100644 --- a/packages/@lightningjs/ui-components/src/components/FocusManager/FocusManager.test.js +++ b/packages/@lightningjs/ui-components/src/components/FocusManager/FocusManager.test.js @@ -197,6 +197,7 @@ describe('FocusManager', () => { const pos = 100; focusManager.itemPosX = pos; focusManager.itemPosY = pos; + testRenderer.forceAllUpdates(); expect(focusManager.Items.x).toBe(pos); expect(focusManager.Items.y).toBe(pos);