fix: getting much closer to my idea
This commit is contained in:
@@ -596,6 +596,7 @@ export const MenuEditorView: React.FC = () => {
|
|||||||
placeholder={tr('menuEditor.newEntryPlaceholder')}
|
placeholder={tr('menuEditor.newEntryPlaceholder')}
|
||||||
disabled={isLoadingPages}
|
disabled={isLoadingPages}
|
||||||
autoFocus
|
autoFocus
|
||||||
|
inlinePlain
|
||||||
/>
|
/>
|
||||||
) : node.data.title}
|
) : node.data.title}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
18
src/renderer/components/PageInput/PageInput.css
Normal file
18
src/renderer/components/PageInput/PageInput.css
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
.page-input-wrapper-inline {
|
||||||
|
padding: 0;
|
||||||
|
min-height: 0;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-input-wrapper-inline:focus-within {
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-input-field-inline {
|
||||||
|
min-width: 0;
|
||||||
|
padding: 0;
|
||||||
|
line-height: 1.25;
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import type { PostData } from '../../../main/shared/electronApi';
|
import type { PostData } from '../../../main/shared/electronApi';
|
||||||
import '../TagInput/TagInput.css';
|
import '../TagInput/TagInput.css';
|
||||||
|
import './PageInput.css';
|
||||||
|
|
||||||
interface PageInputProps {
|
interface PageInputProps {
|
||||||
pages: PostData[];
|
pages: PostData[];
|
||||||
@@ -10,6 +11,7 @@ interface PageInputProps {
|
|||||||
createSubmenuLabel: string;
|
createSubmenuLabel: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
autoFocus?: boolean;
|
autoFocus?: boolean;
|
||||||
|
inlinePlain?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PageInput: React.FC<PageInputProps> = ({
|
export const PageInput: React.FC<PageInputProps> = ({
|
||||||
@@ -20,6 +22,7 @@ export const PageInput: React.FC<PageInputProps> = ({
|
|||||||
createSubmenuLabel,
|
createSubmenuLabel,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
autoFocus = false,
|
autoFocus = false,
|
||||||
|
inlinePlain = false,
|
||||||
}) => {
|
}) => {
|
||||||
const [inputValue, setInputValue] = useState('');
|
const [inputValue, setInputValue] = useState('');
|
||||||
const [showSuggestions, setShowSuggestions] = useState(false);
|
const [showSuggestions, setShowSuggestions] = useState(false);
|
||||||
@@ -127,11 +130,11 @@ export const PageInput: React.FC<PageInputProps> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="tag-input-container" ref={containerRef}>
|
<div className="tag-input-container" ref={containerRef}>
|
||||||
<div className="tag-input-wrapper">
|
<div className={`tag-input-wrapper ${inlinePlain ? 'page-input-wrapper-inline' : ''}`}>
|
||||||
<input
|
<input
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
type="text"
|
type="text"
|
||||||
className="tag-input-field"
|
className={`tag-input-field ${inlinePlain ? 'page-input-field-inline' : ''}`}
|
||||||
value={inputValue}
|
value={inputValue}
|
||||||
autoFocus={autoFocus}
|
autoFocus={autoFocus}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ describe('MenuEditorView entry editor', () => {
|
|||||||
fireEvent.input(input, { target: { value: 'ab' } });
|
fireEvent.input(input, { target: { value: 'ab' } });
|
||||||
const suggestion = await screen.findByRole('button', { name: /^about$/i });
|
const suggestion = await screen.findByRole('button', { name: /^about$/i });
|
||||||
expect(suggestion.className).toContain('tag-suggestion');
|
expect(suggestion.className).toContain('tag-suggestion');
|
||||||
|
|
||||||
|
const wrapper = input.closest('.tag-input-wrapper');
|
||||||
|
expect(wrapper).not.toBeNull();
|
||||||
|
expect(wrapper?.className).toContain('page-input-wrapper-inline');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('focuses the new in-row page input immediately after creating an entry', async () => {
|
it('focuses the new in-row page input immediately after creating an entry', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user