1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-18 13:11:17 +02:00

fix void node cursor navigation in firefox

This commit is contained in:
Ian Storm Taylor
2016-07-27 12:52:00 -07:00
parent 42cbcb7e8d
commit b9ae5d2af6

View File

@@ -5,6 +5,7 @@ import OffsetKey from '../utils/offset-key'
import React from 'react'
import ReactDOM from 'react-dom'
import keycode from 'keycode'
import { IS_FIREFOX } from '../utils/environment'
/**
* Void.
@@ -109,15 +110,26 @@ class Void extends React.Component {
*/
renderSpacer = () => {
const style = {
position: 'absolute',
top: '0px',
left: '-9999px',
textIndent: '-9999px'
}
// COMPAT: In Firefox, if the <span> is positioned absolutely, it won't
// receive the cursor properly when navigating via arrow keys.
const style = IS_FIREFOX
? {
pointerEvents: 'none',
width: '0px',
height: '0px',
lineHeight: '0px',
visibility: 'hidden'
}
: {
pointerEvents: 'none',
position: 'absolute',
top: '0px',
left: '-9999px',
textIndent: '-9999px'
}
return (
<span style={style}>{this.renderLeaf()}</span>
<span style={style}><span>{this.renderLeaf()}</span></span>
)
}