mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 18:26:26 +00:00
Tooltip misplaced (#3499)
* fix bug: tooltip misplaced * Transition only opacity attributes
This commit is contained in:
@@ -21,7 +21,9 @@ const FolderIcon = ({ className, color, isActive }) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {boolean} isActive
|
* @param {boolean} isActive
|
||||||
|
* @param {object} tooltipRef,
|
||||||
* @param {Function} handleButtonClick
|
* @param {Function} handleButtonClick
|
||||||
|
* @param {Function} handleMouseEnter
|
||||||
* @param {Function} handleContextMenu
|
* @param {Function} handleContextMenu
|
||||||
* @param {string} folderName
|
* @param {string} folderName
|
||||||
* @param {string} folderColor
|
* @param {string} folderColor
|
||||||
@@ -35,7 +37,9 @@ const FolderIcon = ({ className, color, isActive }) => {
|
|||||||
const StorageItem = ({
|
const StorageItem = ({
|
||||||
styles,
|
styles,
|
||||||
isActive,
|
isActive,
|
||||||
|
tooltipRef,
|
||||||
handleButtonClick,
|
handleButtonClick,
|
||||||
|
handleMouseEnter,
|
||||||
handleContextMenu,
|
handleContextMenu,
|
||||||
folderName,
|
folderName,
|
||||||
folderColor,
|
folderColor,
|
||||||
@@ -49,6 +53,7 @@ const StorageItem = ({
|
|||||||
<button
|
<button
|
||||||
styleName={isActive ? 'folderList-item--active' : 'folderList-item'}
|
styleName={isActive ? 'folderList-item--active' : 'folderList-item'}
|
||||||
onClick={handleButtonClick}
|
onClick={handleButtonClick}
|
||||||
|
onMouseEnter={handleMouseEnter}
|
||||||
onContextMenu={handleContextMenu}
|
onContextMenu={handleContextMenu}
|
||||||
onDrop={handleDrop}
|
onDrop={handleDrop}
|
||||||
onDragEnter={handleDragEnter}
|
onDragEnter={handleDragEnter}
|
||||||
@@ -75,7 +80,9 @@ const StorageItem = ({
|
|||||||
<span styleName='folderList-item-noteCount'>{noteCount}</span>
|
<span styleName='folderList-item-noteCount'>{noteCount}</span>
|
||||||
)}
|
)}
|
||||||
{isFolded && (
|
{isFolded && (
|
||||||
<span styleName='folderList-item-tooltip'>{folderName}</span>
|
<span styleName='folderList-item-tooltip' ref={tooltipRef}>
|
||||||
|
{folderName}
|
||||||
|
</span>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
@@ -83,7 +90,9 @@ const StorageItem = ({
|
|||||||
|
|
||||||
StorageItem.propTypes = {
|
StorageItem.propTypes = {
|
||||||
isActive: PropTypes.bool.isRequired,
|
isActive: PropTypes.bool.isRequired,
|
||||||
|
tooltipRef: PropTypes.object,
|
||||||
handleButtonClick: PropTypes.func,
|
handleButtonClick: PropTypes.func,
|
||||||
|
handleMouseEnter: PropTypes.func,
|
||||||
handleContextMenu: PropTypes.func,
|
handleContextMenu: PropTypes.func,
|
||||||
folderName: PropTypes.string.isRequired,
|
folderName: PropTypes.string.isRequired,
|
||||||
folderColor: PropTypes.string,
|
folderColor: PropTypes.string,
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
border-bottom-right-radius 2px
|
border-bottom-right-radius 2px
|
||||||
height 34px
|
height 34px
|
||||||
line-height 32px
|
line-height 32px
|
||||||
|
transition-property opacity
|
||||||
|
|
||||||
.folderList-item:hover, .folderList-item--active:hover
|
.folderList-item:hover, .folderList-item--active:hover
|
||||||
.folderList-item-tooltip
|
.folderList-item-tooltip
|
||||||
|
|||||||
@@ -144,6 +144,15 @@ class StorageItem extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleFolderMouseEnter(e, tooltipRef, isFolded) {
|
||||||
|
if (isFolded) {
|
||||||
|
const buttonEl = e.currentTarget
|
||||||
|
const tooltipEl = tooltipRef.current
|
||||||
|
|
||||||
|
tooltipEl.style.top = buttonEl.getBoundingClientRect().y + 'px'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handleFolderButtonContextMenu(e, folder) {
|
handleFolderButtonContextMenu(e, folder) {
|
||||||
context.popup([
|
context.popup([
|
||||||
{
|
{
|
||||||
@@ -316,6 +325,7 @@ class StorageItem extends React.Component {
|
|||||||
folder.key
|
folder.key
|
||||||
)
|
)
|
||||||
const isActive = !!location.pathname.match(folderRegex)
|
const isActive = !!location.pathname.match(folderRegex)
|
||||||
|
const tooltipRef = React.createRef(null)
|
||||||
const noteSet = folderNoteMap.get(storage.key + '-' + folder.key)
|
const noteSet = folderNoteMap.get(storage.key + '-' + folder.key)
|
||||||
|
|
||||||
let noteCount = 0
|
let noteCount = 0
|
||||||
@@ -339,7 +349,11 @@ class StorageItem extends React.Component {
|
|||||||
key={folder.key}
|
key={folder.key}
|
||||||
index={index}
|
index={index}
|
||||||
isActive={isActive || folder.key === this.state.draggedOver}
|
isActive={isActive || folder.key === this.state.draggedOver}
|
||||||
|
tooltipRef={tooltipRef}
|
||||||
handleButtonClick={e => this.handleFolderButtonClick(folder.key)(e)}
|
handleButtonClick={e => this.handleFolderButtonClick(folder.key)(e)}
|
||||||
|
handleMouseEnter={e =>
|
||||||
|
this.handleFolderMouseEnter(e, tooltipRef, isFolded)
|
||||||
|
}
|
||||||
handleContextMenu={e => this.handleFolderButtonContextMenu(e, folder)}
|
handleContextMenu={e => this.handleFolderButtonContextMenu(e, folder)}
|
||||||
folderName={folder.name}
|
folderName={folder.name}
|
||||||
folderColor={folder.color}
|
folderColor={folder.color}
|
||||||
|
|||||||
Reference in New Issue
Block a user