@lightningjs/blits 1.35.1 → 1.35.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.35.2
4
+
5
+ _25 Jul 2025_
6
+
7
+ - Fixed issue with focus getting lost when destroying a focused component
8
+ - Fixed issue with refocusing a component that's already in the focus chain (i.e. `this.parent.$focus()`)
9
+
3
10
  ## v1.35.1
4
11
 
5
12
  _24 Jul 2025_
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "1.35.1",
3
+ "version": "1.35.2",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.js",
6
6
  "exports": {
@@ -40,6 +40,10 @@ export default {
40
40
  * @this {import('../../component').BlitsComponent}
41
41
  */
42
42
  value: function (e) {
43
+ // force refocus when the component is already in focused state
44
+ if (this.lifecycle.state === 'focus') {
45
+ this.lifecycle.state = 'refocus'
46
+ }
43
47
  Focus.set(this, e)
44
48
  },
45
49
  writable: false,
@@ -66,6 +70,10 @@ export default {
66
70
  this.eol = true
67
71
  this.lifecycle.state = 'destroy'
68
72
 
73
+ // when destroying a component that currently has focus
74
+ // pass focus to the parent so we don't get lost in focus limbo
75
+ if (this.hasFocus === true) this.parent.$focus()
76
+
69
77
  for (let key in this[symbols.state]) {
70
78
  if (Array.isArray(this[symbols.state][key])) {
71
79
  this[symbols.state][key] = []
package/src/component.js CHANGED
@@ -111,6 +111,7 @@ const required = (name) => {
111
111
  *
112
112
  * @typedef {object} BlitsComponent
113
113
  * Main properties of the Blits component:
114
+ * @property {boolean?} eol - Indicates when a component is End of Life
114
115
  * @property {string} componentId - The unique identifier for the component instance
115
116
  * @property {BlitsLifecycle} lifecycle - The lifecycle object for the component instance
116
117
  * @property {BlitsComponent} parent - The parent component of the current component instance
@@ -70,14 +70,15 @@ export default {
70
70
  * @param {string} v - The new lifecycle state.
71
71
  */
72
72
  set state(v) {
73
- if (states.indexOf(v) > -1 && v !== this.current) {
73
+ if ((states.indexOf(v) > -1 && v !== this.current) || v === 'refocus') {
74
74
  Log.debug(
75
75
  `Setting lifecycle state from ${this.current} to ${v} for ${this.component.componentId}`
76
76
  )
77
77
  this.previous = this.current
78
78
  this.current = v
79
- if (this.current === 'focus') this.component[symbols.state].hasFocus = true
80
- if (this.current === 'unfocus') this.component[symbols.state].hasFocus = false
79
+ if (v === 'refocus') return
80
+ if (v === 'focus') this.component[symbols.state].hasFocus = true
81
+ if (v === 'unfocus') this.component[symbols.state].hasFocus = false
81
82
  // emit 'private' hook
82
83
  privateEmit(v, this.component[symbols.identifier], this.component)
83
84
  // emit 'public' hook