Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ellipsize grid expression input #6578

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions editor/src/uuiui/inputs/grid-expression-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export const GridExpressionInput = React.memo(
width: inputFocused ? '100%' : `calc(100% - ${DropdownWidth}px)`,
}}
css={{ color: isDefault ? colorTheme.fg6.value : colorTheme.fg0.value }}
ellipsize={true}
/>
{unless(
inputFocused,
Expand Down
11 changes: 11 additions & 0 deletions editor/src/uuiui/inputs/string-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { jsx } from '@emotion/react'
import styled from '@emotion/styled'
import composeRefs from '@seznam/compose-react-refs'
import type { CSSProperties } from 'react'
import React from 'react'
import type { ControlStatus } from '../../components/inspector/common/control-status'
import type { ControlStyles } from '../../components/inspector/common/control-styles'
Expand Down Expand Up @@ -34,6 +35,7 @@ export interface StringInputProps
pasteHandler?: boolean
showBorder?: boolean
innerStyle?: React.CSSProperties
ellipsize?: boolean
}

export const StringInput = React.memo(
Expand All @@ -49,6 +51,7 @@ export const StringInput = React.memo(
DEPRECATED_labelBelow: labelBelow,
testId,
showBorder,
ellipsize,
...inputProps
},
propsRef,
Expand Down Expand Up @@ -88,6 +91,13 @@ export const StringInput = React.memo(

const placeholder = getControlStylesAwarePlaceholder(controlStyles) ?? initialPlaceHolder

let inputStyle: CSSProperties = {}
if (ellipsize) {
inputStyle.textOverflow = 'ellipsis'
inputStyle.whiteSpace = 'nowrap'
inputStyle.overflow = 'hidden'
}

return (
<form
autoComplete='off'
Expand Down Expand Up @@ -142,6 +152,7 @@ export const StringInput = React.memo(
autoComplete='off'
spellCheck={false}
growInputAutomatically={inputProps.growInputAutomatically}
style={inputStyle}
/>
{labelBelow == null ? null : (
<LabelBelow htmlFor={inputProps.id} style={{ color: controlStyles.secondaryColor }}>
Expand Down
Loading