Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Flexible widget title input field width (#8516)

Benjamin Bädorf20eb533b07d6
diff --git a/frontend/src/app/modules/common/editable-toolbar-title/editable-toolbar-title.html b/frontend/src/app/modules/common/editable-toolbar-title/editable-toolbar-title.html
index 26e6bfe9289..ffe7017a4a0 100644
--- a/frontend/src/app/modules/common/editable-toolbar-title/editable-toolbar-title.html
+++ b/frontend/src/app/modules/common/editable-toolbar-title/editable-toolbar-title.html
@@ -10,6 +10,7 @@
<span aria-hidden="true" class="icon icon-save"></span>
</a>
<input #editableTitleInput
+ size="1"
type="text"
aria-required="true"
[attr.name]="selectableTitleIdentifier"
@@ -24,6 +25,10 @@
[disabled]="inFlight"
[ngClass]="{ '-error': isEmpty, '-changed': showSave }"
class="editable-toolbar-title--input -border-on-hover-only toolbar--editable-toolbar ellipsis"/>
+ <!-- This is not an angular component, rather it is a custom element so the specificity of the css stays low.
+ The &nbsp;&nbsp; is for making sure that the shim is always a bit larger than the input. Sometimes the ellipsis
+ would kick in to early otherwise. -->
+ <input-shim class="editable-toolbar-title--input editable-toolbar-title--input-shim toolbar--editable-toolbar">{{ selectedTitle || text.input_placeholder }}{{ selectedTitle ? '&nbsp;&nbsp;' : ''}}</input-shim>
</div>
<h2 *ngIf="!editable"
[attr.title]="selectedTitle"
diff --git a/frontend/src/app/modules/common/editable-toolbar-title/editable-toolbar-title.sass b/frontend/src/app/modules/common/editable-toolbar-title/editable-toolbar-title.sass
index 76a05b995da..f6c2b0f15bb 100644
--- a/frontend/src/app/modules/common/editable-toolbar-title/editable-toolbar-title.sass
+++ b/frontend/src/app/modules/common/editable-toolbar-title/editable-toolbar-title.sass
@@ -1,12 +1,26 @@
.editable-toolbar-title--container
- display: flex
+ display: grid
align-items: center
+ grid-template-columns: auto auto 1fr
+
+ &::before
+ &::after
+ display: block
+ content: ''
+
+ &::before
+ grid-area: 1/1
+
+ &::after
+ grid-area: 1/3
.editable-toolbar-title--fixed
padding: 0
cursor: default
.editable-toolbar-title--save
+ grid-area: 1/1
+
span:before
color: #5F5F5F
@@ -14,8 +28,30 @@
color: darken(#5F5F5F, 20%)
.editable-toolbar-title--input
- padding-left: 5px
color: #5F5F5F
+ &:focus
+ border-color: #999
+ box-shadow: 0 0 0 1px #999
+
&.-changed
font-style: italic
+
+.editable-toolbar-title--input
+ display: block
+ grid-area: 1/2
+ padding-left: 5px
+ width: auto
+ min-width: 1em
+
+.editable-toolbar-title--input-shim
+ visibility: hidden
+ white-space: pre
+
+// Here we make sure the shim layouts like the normal input
+// This is an element selector so the specificity stays lower than other selectors that might write here.
+// The rules are taken from input[type="text"]
+input-shim
+ border: 1px solid transparent
+ padding: 0.375rem
+ margin: 0
diff --git a/frontend/src/global_styles/content/_editable_toolbar.sass b/frontend/src/global_styles/content/_editable_toolbar.sass
index e6a4b29abef..75a596fbeb7 100644
--- a/frontend/src/global_styles/content/_editable_toolbar.sass
+++ b/frontend/src/global_styles/content/_editable_toolbar.sass
@@ -18,7 +18,7 @@
font-size: 1.2rem
line-height: 32px
-input[type="text"].toolbar--editable-toolbar
+.toolbar--editable-toolbar
color: var(--toolbar-title-color)
font-size: 20px
font-weight: bold
diff --git a/frontend/src/global_styles/content/_widget_box.sass b/frontend/src/global_styles/content/_widget_box.sass
index 07825c84da3..e40e103cc67 100644
--- a/frontend/src/global_styles/content/_widget_box.sass
+++ b/frontend/src/global_styles/content/_widget_box.sass
@@ -124,7 +124,7 @@ $widget-box--enumeration-width: 20px
// Ensure style for read-only widget headers
.editable-toolbar-title--fixed,
- input[type="text"].toolbar--editable-toolbar
+ .toolbar--editable-toolbar
color: #5F5F5F
font-size: 16px
letter-spacing: 1px
diff --git a/frontend/src/global_styles/layout/_toolbar.sass b/frontend/src/global_styles/layout/_toolbar.sass
index e1f4f178222..4ebd5ee7cf2 100644
--- a/frontend/src/global_styles/layout/_toolbar.sass
+++ b/frontend/src/global_styles/layout/_toolbar.sass
@@ -204,9 +204,9 @@ $nm-color-success-background: #d8fdd1
// Allow title container to grow
.title-container
flex: 1 1
- overflow: hidden
white-space: nowrap
margin-bottom: 10px
+ max-width: 100%
// margin-bottom of toolbar buttons
&.-no-grow
diff --git a/frontend/src/global_styles/layout/work_packages/_table.sass b/frontend/src/global_styles/layout/work_packages/_table.sass
index 52d38311013..ca513ce4fb9 100644
--- a/frontend/src/global_styles/layout/work_packages/_table.sass
+++ b/frontend/src/global_styles/layout/work_packages/_table.sass
@@ -54,7 +54,7 @@
> .toolbar-container
margin-top: 5px
- input[type="text"].toolbar--editable-toolbar
+ .toolbar--editable-toolbar
font-size: 24px
// Match both rows and timeline specifically