Skip to content

Commit 129e413

Browse files
committed
Fix: parent node touch, SafeAreaView wrapper android
1 parent f40715c commit 129e413

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

example/components/DomCounter.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
import { Platform } from 'react-native'
2+
13
export default function DomApp() {
24
let count = 0
5+
let saView
6+
if (Platform.OS === 'android') {
7+
saView = document.createElement('View')
8+
} else {
9+
saView = document.createElement('SafeAreaView')
10+
}
311

4-
const saView = document.createElement('SafeAreaView')
512
const view = document.createElement('View')
613
const text = document.createElement('Text')
714
text.textContent = count

src/components.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
import { Platform } from 'react-native'
12
import { h } from 'preact'
23

34
export function SafeAreaView({ ...props }) {
4-
return h('SafeAreaView', props)
5+
let compName = 'SafeAreaView'
6+
if (Platform.OS === 'android') {
7+
compName = 'View'
8+
}
9+
return h(compName, props)
510
}
611

712
export function View({ ...props }) {

src/dom/bridge.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ class Bridge {
8888
if (Object.keys(FALSE_TYPES).indexOf(type) > -1) {
8989
break
9090
}
91-
const rawViewClass = TYPES[type]
9291

92+
const rawViewClass = TYPES[type]
9393
if (type === '#text') {
9494
ReactNativePrivateInterface.UIManager.createView(
9595
binding.id,
@@ -153,8 +153,6 @@ class Bridge {
153153
parentTag = ROOT_TAG
154154
}
155155

156-
// if conflicting indices between create and move,
157-
// add the child at a later index and then to the remaining
158156
ReactNativePrivateInterface.UIManager.manageChildren(
159157
parentTag, // containerID
160158
moveFrom, // moveFromIndices
@@ -167,6 +165,7 @@ class Bridge {
167165
break
168166
}
169167
case 'event': {
168+
const targetId = params[0]
170169
this.handleEvent('event', params)
171170
break
172171
}
@@ -363,6 +362,9 @@ function receiveTouches(eventTopLevelType, touches, changedIndices) {
363362
return
364363
}
365364

365+
if (nodeId === registry.root) {
366+
return
367+
}
366368
executeTouchEvent.call(this, nodeId, eventTopLevelType, nativeEvent)
367369
}
368370

@@ -378,14 +380,18 @@ function executeKeyboardEvent(nodeId, eventTopLevelType, nativeEvent = {}) {
378380
this.enqueue('event', [nodeId, eventTopLevelType, nativeEvent])
379381
}
380382

383+
// TODO: if used somewhere else, add to
384+
// a shared folder
385+
const microTask = fn => setTimeout(fn, 1)
386+
381387
function process() {
382388
const q = this.queue || []
383389
let methodDef = q.shift()
384390
if (methodDef) {
385391
dispatch.call(this, methodDef)
386-
// setTimeout(() => {
387-
process.call(this)
388-
// }, 1)
392+
microTask(() => {
393+
process.call(this)
394+
})
389395
} else {
390396
this.processing = false
391397
}

0 commit comments

Comments
 (0)