mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Allow text selection in log entry header (#30638)
GitOrigin-RevId: 18c6c9bc9b2971dbd877ce7d053a2582c6d072ad
This commit is contained in:
+24
-3
@@ -1,5 +1,12 @@
|
|||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
import { useState, useRef, MouseEventHandler, ElementType } from 'react'
|
import {
|
||||||
|
useState,
|
||||||
|
useRef,
|
||||||
|
MouseEventHandler,
|
||||||
|
ElementType,
|
||||||
|
useCallback,
|
||||||
|
KeyboardEventHandler,
|
||||||
|
} from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import OLTooltip from '@/shared/components/ol/ol-tooltip'
|
import OLTooltip from '@/shared/components/ol/ol-tooltip'
|
||||||
import {
|
import {
|
||||||
@@ -105,16 +112,30 @@ function LogEntryHeader({
|
|||||||
!!fileData &&
|
!!fileData &&
|
||||||
!(fileData.entity._id === openEntity?.entity._id && !line)
|
!(fileData.entity._id === openEntity?.entity._id && !line)
|
||||||
|
|
||||||
|
const handleKeyDown: KeyboardEventHandler<HTMLDivElement> = useCallback(
|
||||||
|
event => {
|
||||||
|
if (event.key === 'Enter' || event.key === ' ') {
|
||||||
|
event.preventDefault()
|
||||||
|
onToggleCollapsed()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[onToggleCollapsed]
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className="log-entry-header-card">
|
<header className="log-entry-header-card">
|
||||||
<button
|
<div
|
||||||
data-action="expand-collapse"
|
data-action="expand-collapse"
|
||||||
data-collapsed={collapsed}
|
data-collapsed={collapsed}
|
||||||
className="log-entry-header-button"
|
className="log-entry-header-button"
|
||||||
onClick={onToggleCollapsed}
|
onClick={onToggleCollapsed}
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
aria-label={collapsed ? t('expand') : t('collapse')}
|
aria-label={collapsed ? t('expand') : t('collapse')}
|
||||||
>
|
>
|
||||||
<MaterialIcon
|
<MaterialIcon
|
||||||
|
className="log-entry-expand-icon"
|
||||||
type={
|
type={
|
||||||
openCollapseIconOverride ??
|
openCollapseIconOverride ??
|
||||||
(collapsed ? 'chevron_right' : 'expand_more')
|
(collapsed ? 'chevron_right' : 'expand_more')
|
||||||
@@ -135,7 +156,7 @@ function LogEntryHeader({
|
|||||||
formattedLocationText
|
formattedLocationText
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</div>
|
||||||
|
|
||||||
{actionButtonsOverride ?? (
|
{actionButtonsOverride ?? (
|
||||||
<div className="log-entry-header-actions">
|
<div className="log-entry-header-actions">
|
||||||
|
|||||||
@@ -89,17 +89,20 @@
|
|||||||
border-radius: var(--border-radius-base);
|
border-radius: var(--border-radius-base);
|
||||||
padding: var(--spacing-02) 0;
|
padding: var(--spacing-02) 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
user-select: text;
|
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover,
|
&:hover,
|
||||||
:focus,
|
&:focus-visible,
|
||||||
:active {
|
&:active {
|
||||||
background-color: var(--bg-secondary-themed);
|
background-color: var(--bg-secondary-themed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.log-entry-expand-icon {
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.log-entry-header-content {
|
.log-entry-header-content {
|
||||||
|
|||||||
Reference in New Issue
Block a user