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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix column position after page is loaded to prevent reflow
Inga Maice4bc081bf0c
diff --git a/frontend/src/app/components/wp-form-group/wp-attribute-group.component.ts b/frontend/src/app/components/wp-form-group/wp-attribute-group.component.tsindex 47f8f7cf462..91d72650cc9 100644--- a/frontend/src/app/components/wp-form-group/wp-attribute-group.component.ts+++ b/frontend/src/app/components/wp-form-group/wp-attribute-group.component.ts@@ -26,7 +26,7 @@// See docs/COPYRIGHT.rdoc for more details.// ++-import {Component, Injector, Input} from '@angular/core';+import {Component, Injector, Input, AfterViewInit} from '@angular/core';import {I18nService} from 'core-app/modules/common/i18n/i18n.service';import {FieldDescriptor, GroupDescriptor} from 'core-components/work-packages/wp-single-view/wp-single-view.component';import {WorkPackageResource} from 'core-app/modules/hal/resources/work-package-resource';@@ -36,7 +36,7 @@ import {EditFormComponent} from "core-app/modules/fields/edit/edit-form/edit-forselector: 'wp-attribute-group',templateUrl: './wp-attribute-group.template.html'})-export class WorkPackageFormAttributeGroupComponent {+export class WorkPackageFormAttributeGroupComponent implements AfterViewInit {@Input() public workPackage:WorkPackageResource;@Input() public group:GroupDescriptor;@@ -45,6 +45,10 @@ export class WorkPackageFormAttributeGroupComponent {protected injector:Injector) {}+ ngAfterViewInit() {+ setTimeout(() => this.fixColumns());+ }+public trackByName(_index:number, elem:{ name:string }) {return elem.name;}@@ -65,4 +69,24 @@ export class WorkPackageFormAttributeGroupComponent {return name;}}-}++ /**+ * Fix the top of the columns after view has been loaded+ * to prevent columns from repositioning (e.g. when editing multi-select fields)+ */+ private fixColumns() {+ let lastOffset = 0;+ // Find corresponding HTML of attribute fields for each group+ let htmlAttributes = jQuery('div.attributes-group:contains(' + this.group.name + ')').find('.attributes-key-value');++ htmlAttributes.each(function() {+ let offset = jQuery(this).position().top;++ if (offset < lastOffset) {+ // Fix position of the column start+ jQuery(this).addClass('-column-start');+ }+ lastOffset = offset;+ });+ }+}\ No newline at end of filediff --git a/frontend/src/app/modules/fields/edit/field/editable-attribute-field.component.ts b/frontend/src/app/modules/fields/edit/field/editable-attribute-field.component.tsindex 9bb90b2c9f6..949426dc997 100644--- a/frontend/src/app/modules/fields/edit/field/editable-attribute-field.component.ts+++ b/frontend/src/app/modules/fields/edit/field/editable-attribute-field.component.ts@@ -118,8 +118,6 @@ export class EditableAttributeFieldComponent extends UntilDestroyedMixin implemethis.resource = resource;this.render();});-- this.calcRows();}// Open the field when its closed and relay drag & drop events to it.@@ -147,8 +145,6 @@ export class EditableAttributeFieldComponent extends UntilDestroyedMixin implemeif (focus) {setTimeout(() => this.$element.find(`.${displayClassName}`).focus(), 20);}-- this.calcRows();}public get isEditable() {@@ -221,19 +217,4 @@ export class EditableAttributeFieldComponent extends UntilDestroyedMixin implemereturn this.schemaCache.of(this.resource) as ISchemaProxy;}}-- /**- * Calculate the number of rows each edit field should span- * to create more of a 'masonry' layout look without large gaps- */- public calcRows() {- const rowHeight = 38;- let elem = jQuery(this.displayContainer.nativeElement);- let elemHeight = elem.height();-- if (elemHeight !== undefined && elemHeight > rowHeight) {- let rowspan = Math.ceil(elemHeight / rowHeight);- elem.closest('.attributes-key-value').css('grid-row', 'span ' + rowspan);- }- }}diff --git a/frontend/src/global_styles/openproject/_mixins.sass b/frontend/src/global_styles/openproject/_mixins.sassindex ac0a4024490..f7c70172463 100644--- a/frontend/src/global_styles/openproject/_mixins.sass+++ b/frontend/src/global_styles/openproject/_mixins.sass@@ -133,14 +133,17 @@ $scrollbar-size: 10pxvisibility: hidden@mixin two-column-layout- display: grid- grid-template-columns: repeat(auto-fill, minmax(45%, 1fr))- grid-gap: 0 3rem+ column-count: 2+ column-gap: 3rem++ .attributes-key-value.-column-start+ column-break-before: always !important+ break-before: column@supports (column-span: all)// Let some elements still span both columns.attributes-key-value.-span-all-columns- grid-column: -1/1+ column-span: all.attributes-key-value--keyflex-basis: calc(22.5% - (4rem / 6)).attributes-key-value--value-container