Correctly patch inactive input in Safari

This commit is contained in:
Alexander Zinchuk 2023-07-21 17:47:32 +02:00
parent 418ef49062
commit c91fb99c05
8 changed files with 11 additions and 11 deletions

View File

@ -223,7 +223,7 @@ const ChatExtra: FC<OwnProps & StateProps> = ({
narrow narrow
isStatic isStatic
> >
<span className="title word-break text-selection" dir="auto"> <span className="title word-break allow-selection" dir="auto">
{renderText(description, ['br', 'links', 'emoji'])} {renderText(description, ['br', 'links', 'emoji'])}
</span> </span>
<span className="subtitle">{lang(userId ? 'UserBio' : 'Info')}</span> <span className="subtitle">{lang(userId ? 'UserBio' : 'Info')}</span>

View File

@ -70,7 +70,7 @@ const MediaViewerFooter: FC<OwnProps> = ({
<div className={classNames} onClick={stopEvent}> <div className={classNames} onClick={stopEvent}>
{Boolean(text) && ( {Boolean(text) && (
<div className="media-viewer-footer-content" onClick={!isMobile ? onClick : undefined}> <div className="media-viewer-footer-content" onClick={!isMobile ? onClick : undefined}>
<p className={`media-text custom-scroll text-selection ${isMultiline ? 'multiline' : ''}`} dir="auto"> <p className={`media-text custom-scroll allow-selection ${isMultiline ? 'multiline' : ''}`} dir="auto">
{text} {text}
</p> </p>
</div> </div>

View File

@ -521,7 +521,7 @@ const MessageInput: FC<OwnProps & StateProps> = ({
const isTouched = useDerivedState(() => Boolean(isActive && getHtml()), [isActive, getHtml]); const isTouched = useDerivedState(() => Boolean(isActive && getHtml()), [isActive, getHtml]);
const className = buildClassName( const className = buildClassName(
'form-control', 'form-control allow-selection',
isTouched && 'touched', isTouched && 'touched',
shouldSuppressFocus && 'focus-disabled', shouldSuppressFocus && 'focus-disabled',
); );

View File

@ -563,7 +563,7 @@ const Message: FC<OwnProps & StateProps> = ({
}, [focusLastMessage, isLastInList, transcribedText, withVoiceTranscription]); }, [focusLastMessage, isLastInList, transcribedText, withVoiceTranscription]);
const containerClassName = buildClassName( const containerClassName = buildClassName(
'Message message-list-item text-selection', 'Message message-list-item allow-selection',
isFirstInGroup && 'first-in-group', isFirstInGroup && 'first-in-group',
isProtected && 'is-protected', isProtected && 'is-protected',
isLastInGroup && 'last-in-group', isLastInGroup && 'last-in-group',

View File

@ -195,7 +195,7 @@ const ListItem: FC<OwnProps> = ({
const fullClassName = buildClassName( const fullClassName = buildClassName(
'ListItem', 'ListItem',
className, className,
isStatic && 'text-selection', isStatic && 'allow-selection',
ripple && 'has-ripple', ripple && 'has-ripple',
narrow && 'narrow', narrow && 'narrow',
disabled && 'disabled', disabled && 'disabled',

View File

@ -31,14 +31,14 @@ const useContextMenuHandlers = (
const handleBeforeContextMenu = useLastCallback((e: React.MouseEvent) => { const handleBeforeContextMenu = useLastCallback((e: React.MouseEvent) => {
if (!isMenuDisabled && e.button === 2) { if (!isMenuDisabled && e.button === 2) {
requestMutation(() => { requestMutation(() => {
removeExtraClass(e.target as HTMLElement, 'text-selection'); removeExtraClass(e.target as HTMLElement, 'allow-selection');
}); });
} }
}); });
const handleContextMenu = useLastCallback((e: React.MouseEvent) => { const handleContextMenu = useLastCallback((e: React.MouseEvent) => {
requestMutation(() => { requestMutation(() => {
addExtraClass(e.target as HTMLElement, 'text-selection'); addExtraClass(e.target as HTMLElement, 'allow-selection');
}); });
if (isMenuDisabled || (shouldDisableOnLink && (e.target as HTMLElement).matches('a[href]'))) { if (isMenuDisabled || (shouldDisableOnLink && (e.target as HTMLElement).matches('a[href]'))) {

View File

@ -25,6 +25,7 @@ body {
overscroll-behavior: none; overscroll-behavior: none;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
user-select: none;
--font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Apple Color Emoji", "Segoe UI", Oxygen, Ubuntu, Cantarell, --font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Apple Color Emoji", "Segoe UI", Oxygen, Ubuntu, Cantarell,
"Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
@ -115,8 +116,8 @@ body.cursor-ew-resize {
visibility: hidden; visibility: hidden;
} }
.text-selection { .allow-selection {
user-select: text !important; user-select: text;
} }
.clearfix::after { .clearfix::after {
@ -167,8 +168,6 @@ body.cursor-ew-resize {
} }
body:not(.is-ios) { body:not(.is-ios) {
user-select: none; // On iOS, disallowing user selection breaks focus in text input fields
.custom-scroll { .custom-scroll {
&::-webkit-scrollbar { &::-webkit-scrollbar {
width: 0.375rem; width: 0.375rem;

View File

@ -5,6 +5,7 @@ export default function deleteLastCharacterOutsideSelection(html: string) {
tempInput.style.left = '-10000px'; tempInput.style.left = '-10000px';
tempInput.style.top = '-10000px'; tempInput.style.top = '-10000px';
tempInput.innerHTML = html; tempInput.innerHTML = html;
tempInput.className = 'allow-selection'; // Patch for Safari
document.body.appendChild(tempInput); document.body.appendChild(tempInput);
let element = tempInput.lastChild!; let element = tempInput.lastChild!;