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

Always display input for widget title in widget edit mode. #19737

Merged
merged 3 commits into from
Jul 1, 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
5 changes: 5 additions & 0 deletions changelog/unreleased/issue-7396.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type="c"
message="Always display input for widget title in widget edit mode."

issues=["7396"]
pulls=["19737"]
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ const Widget = ({ id, editing, widget, title, position, onPositionsChange }: Pro
<WidgetHeader title={title}
hideDragHandle={!interactive || isFocused}
loading={loading}
editing={editing}
onRename={onRenameWidget}>
{!editing ? (
<WidgetActionsMenu isFocused={isFocused}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import styled, { css } from 'styled-components';

import { Spinner, Icon } from 'components/common';
import EditableTitle from 'views/components/common/EditableTitle';
import { Input } from 'components/bootstrap';

import CustomPropTypes from '../CustomPropTypes';

Expand All @@ -34,6 +35,11 @@ const Container = styled.div(({ theme }) => css`
display: grid;
grid-template-columns: minmax(35px, 1fr) max-content;
align-items: center;

.widget-title {
width: 100%;
max-width: 400px;
}
`);

const Col = styled.div`
Expand All @@ -57,19 +63,48 @@ const WidgetActionDropdown = styled.span`
position: relative;
`;

const TitleInputWrapper = styled.div`
max-width: 400px;
width: 100%;

.form-group {
margin-bottom: 5px;
width: 100%;
}
`;

const TitleInput = styled(Input)(({ theme }) => css`
font-size: ${theme.fonts.size.large};
width: 100%;
`);

type Props = {
children: React.ReactNode,
onRename: (newTitle: string) => unknown,
hideDragHandle: boolean,
title: string,
loading: boolean,
editing: boolean,
};

const WidgetHeader = ({ children, onRename, hideDragHandle, title, loading }: Props) => (
const WidgetHeader = ({ children, onRename, hideDragHandle, title, loading, editing }: Props) => (
<Container>
<Col>
{hideDragHandle || <DragHandleContainer className="widget-drag-handle" title={`Drag handle for ${title}`}><WidgetDragHandle name="drag_indicator" /></DragHandleContainer>}
<EditableTitle key={title} disabled={!onRename} value={title} onChange={onRename} />
{editing ? (
<TitleInputWrapper>
<TitleInput type="text"
id="widget-title"
onChange={(e) => onRename(e.target.value)}
value={title}
required />
</TitleInputWrapper>
) : (
<EditableTitle key={title}
disabled={!onRename}
value={title}
onChange={onRename} />
)}
{loading && <LoadingSpinner text="" delay={0} />}
</Col>
<WidgetActionDropdown>
Expand Down
Loading