1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-18 21:21:21 +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 React from 'react'
import ReactDOM from 'react-dom' import ReactDOM from 'react-dom'
import keycode from 'keycode' import keycode from 'keycode'
import { IS_FIREFOX } from '../utils/environment'
/** /**
* Void. * Void.
@@ -109,15 +110,26 @@ class Void extends React.Component {
*/ */
renderSpacer = () => { renderSpacer = () => {
const style = { // COMPAT: In Firefox, if the <span> is positioned absolutely, it won't
position: 'absolute', // receive the cursor properly when navigating via arrow keys.
top: '0px', const style = IS_FIREFOX
left: '-9999px', ? {
textIndent: '-9999px' pointerEvents: 'none',
} width: '0px',
height: '0px',
lineHeight: '0px',
visibility: 'hidden'
}
: {
pointerEvents: 'none',
position: 'absolute',
top: '0px',
left: '-9999px',
textIndent: '-9999px'
}
return ( return (
<span style={style}>{this.renderLeaf()}</span> <span style={style}><span>{this.renderLeaf()}</span></span>
) )
} }