mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 05:01:17 +02:00
fix void node cursor navigation in firefox
This commit is contained in:
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user