@dcl/react-ecs 7.20.4-22489296066.commit-b055846 → 7.20.4-22492765829.commit-3a83d2f
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/reconciler/index.js +16 -0
- package/package.json +3 -3
package/dist/reconciler/index.js
CHANGED
|
@@ -18,6 +18,9 @@ export function createReconciler(engine, pointerEvents) {
|
|
|
18
18
|
// Store the onChange callbacks to be runned every time a Result has changed
|
|
19
19
|
const changeEvents = new Map();
|
|
20
20
|
const clickEvents = new Map();
|
|
21
|
+
// Track the last value reported by the renderer for each input entity,
|
|
22
|
+
// so we can avoid echoing it back and causing keystroke drops.
|
|
23
|
+
const lastInputResultValues = new Map();
|
|
21
24
|
// Initialize components
|
|
22
25
|
const UiTransform = components.UiTransform(engine);
|
|
23
26
|
const UiText = components.UiText(engine);
|
|
@@ -111,6 +114,15 @@ export function createReconciler(engine, pointerEvents) {
|
|
|
111
114
|
delete props.onChange;
|
|
112
115
|
delete props.onSubmit;
|
|
113
116
|
}
|
|
117
|
+
// Prevent keystroke drops: when React echoes back the same value the renderer
|
|
118
|
+
// reported, strip it from the props so the component isn't marked dirty for it.
|
|
119
|
+
// This avoids sending a stale value that overwrites what the user is currently typing.
|
|
120
|
+
if (componentName === 'uiInput' &&
|
|
121
|
+
'value' in props &&
|
|
122
|
+
lastInputResultValues.has(instance.entity) &&
|
|
123
|
+
props.value === lastInputResultValues.get(instance.entity)) {
|
|
124
|
+
delete props.value;
|
|
125
|
+
}
|
|
114
126
|
// We check if there is any key pending to be changed to avoid updating the existing component
|
|
115
127
|
if (!Object.keys(props).length) {
|
|
116
128
|
return;
|
|
@@ -125,6 +137,7 @@ export function createReconciler(engine, pointerEvents) {
|
|
|
125
137
|
function removeChildEntity(instance) {
|
|
126
138
|
changeEvents.delete(instance.entity);
|
|
127
139
|
clickEvents.delete(instance.entity);
|
|
140
|
+
lastInputResultValues.delete(instance.entity);
|
|
128
141
|
engine.removeEntity(instance.entity);
|
|
129
142
|
for (const child of instance._child) {
|
|
130
143
|
removeChildEntity(child);
|
|
@@ -180,6 +193,9 @@ export function createReconciler(engine, pointerEvents) {
|
|
|
180
193
|
if (!hasEvent) {
|
|
181
194
|
const resultComponentId = componentId === UiDropdown.componentId ? UiDropdownResult.componentId : UiInputResult.componentId;
|
|
182
195
|
engine.getComponent(resultComponentId).onChange(entity, (value) => {
|
|
196
|
+
if (resultComponentId === UiInputResult.componentId) {
|
|
197
|
+
lastInputResultValues.set(entity, value?.value);
|
|
198
|
+
}
|
|
183
199
|
if (value?.isSubmit) {
|
|
184
200
|
const onSubmit = changeEvents.get(entity)?.get(componentId)?.onSubmitCallback;
|
|
185
201
|
onSubmit && onSubmit(value?.value);
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/react-ecs",
|
|
3
3
|
"description": "Decentraland ECS",
|
|
4
|
-
"version": "7.20.4-
|
|
4
|
+
"version": "7.20.4-22492765829.commit-3a83d2f",
|
|
5
5
|
"author": "DCL",
|
|
6
6
|
"bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@dcl/ecs": "7.20.4-
|
|
8
|
+
"@dcl/ecs": "7.20.4-22492765829.commit-3a83d2f",
|
|
9
9
|
"react": "^18.2.0",
|
|
10
10
|
"react-reconciler": "^0.29.0"
|
|
11
11
|
},
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"tsconfig": "./tsconfig.json"
|
|
41
41
|
},
|
|
42
42
|
"types": "./dist/index.d.ts",
|
|
43
|
-
"commit": "
|
|
43
|
+
"commit": "3a83d2f48ae4ee0fcd1333086d0240bffed7f00e"
|
|
44
44
|
}
|