diff --git a/packages/frontend/@n8n/design-system/src/components/N8nInlineTextEdit/InlineTextEdit.test.ts b/packages/frontend/@n8n/design-system/src/components/N8nInlineTextEdit/InlineTextEdit.test.ts
index 83c214c28d6..976d28c854e 100644
--- a/packages/frontend/@n8n/design-system/src/components/N8nInlineTextEdit/InlineTextEdit.test.ts
+++ b/packages/frontend/@n8n/design-system/src/components/N8nInlineTextEdit/InlineTextEdit.test.ts
@@ -72,6 +72,32 @@ describe('N8nInlineTextEdit', () => {
expect(preview).toHaveTextContent('New Value!');
});
+ it('should support CSS length values for maxWidth', () => {
+ const wrapper = renderComponent({
+ props: {
+ modelValue: 'Test Value',
+ maxWidth: '80%',
+ },
+ });
+
+ const editableArea = wrapper.getByTestId('inline-editable-area');
+ const preview = wrapper.getByTestId('inline-edit-preview');
+ const input = wrapper.getByTestId('inline-edit-input');
+
+ expect(editableArea).toHaveStyle({
+ width: 'clamp(64px, 1px, 80%)',
+ maxWidth: '80%',
+ });
+ expect(preview).toHaveStyle({
+ width: '100%',
+ maxWidth: '100%',
+ });
+ expect(input).toHaveStyle({
+ width: '100%',
+ maxWidth: '100%',
+ });
+ });
+
it('should not update on escape key press', async () => {
const wrapper = renderComponent({
props: {
diff --git a/packages/frontend/@n8n/design-system/src/components/N8nInlineTextEdit/InlineTextEdit.vue b/packages/frontend/@n8n/design-system/src/components/N8nInlineTextEdit/InlineTextEdit.vue
index 7294d760fbf..a1292027eb2 100644
--- a/packages/frontend/@n8n/design-system/src/components/N8nInlineTextEdit/InlineTextEdit.vue
+++ b/packages/frontend/@n8n/design-system/src/components/N8nInlineTextEdit/InlineTextEdit.vue
@@ -7,7 +7,7 @@ type Props = {
modelValue: string;
readOnly?: boolean;
maxLength?: number;
- maxWidth?: number;
+ maxWidth?: number | string;
minWidth?: number;
placeholder?: string;
disabled?: boolean;
@@ -41,15 +41,29 @@ watchEffect(() => {
// Resize logic
const { width: measuredWidth } = useElementSize(measureSpan);
-const inputWidth = computed(() =>
- Math.max(props.minWidth, Math.min(measuredWidth.value + 1, props.maxWidth)),
+const maxWidth = computed(() =>
+ typeof props.maxWidth === 'number' ? `${props.maxWidth}px` : props.maxWidth,
);
+const inputWidth = computed(() => {
+ const measuredContentWidth = `${measuredWidth.value + 1}px`;
+
+ if (typeof props.maxWidth === 'number') {
+ return `${Math.max(props.minWidth, Math.min(measuredWidth.value + 1, props.maxWidth))}px`;
+ }
+
+ return `clamp(${props.minWidth}px, ${measuredContentWidth}, ${props.maxWidth})`;
+});
const computedInlineStyles = computed(() => ({
- width: `${inputWidth.value}px`,
- maxWidth: `${props.maxWidth}px`,
+ width: inputWidth.value,
+ maxWidth: maxWidth.value,
zIndex: 1,
}));
+const computedContentStyles = {
+ width: '100%',
+ maxWidth: '100%',
+ zIndex: 1,
+};
function forceFocus() {
if (editableRoot.value && !props.readOnly && !props.disabled) {
@@ -117,7 +131,7 @@ defineExpose({ forceFocus, forceCancel });