|
4 | 4 | // ----------------------------- |
5 | 5 | import { computed, ref, toRefs, watch, onMounted, inject } from "vue" |
6 | 6 |
|
| 7 | +// Prevent automatic attribute inheritance to the root element |
| 8 | +// We'll handle it manually to avoid Vue warnings with multiple root elements |
| 9 | +defineOptions({ |
| 10 | + inheritAttrs: false |
| 11 | +}) |
| 12 | +
|
7 | 13 | // ----------------------------- |
8 | 14 | // 2. INTERNAL IMPORTS |
9 | 15 | // ----------------------------- |
@@ -557,45 +563,47 @@ onMounted(() => { |
557 | 563 | </script> |
558 | 564 |
|
559 | 565 | <template> |
560 | | - <!-- Planned Bar (rendered as independent element) --> |
561 | | - <div |
562 | | - v-if="hasPlannedDates && !isGroupBar" |
563 | | - :id="`${barConfig.id}-planned`" |
564 | | - class="g-gantt-planned-bar" |
565 | | - :style="plannedBarStyle" |
566 | | - /> |
567 | | - |
568 | | - <!-- Main Bar --> |
569 | | - <div |
570 | | - :id="barConfig.id" |
571 | | - :class="['g-gantt-bar', barConfig.class || '']" |
572 | | - :style="{ |
573 | | - ...barConfig.style, |
574 | | - position: 'absolute', |
575 | | - top: `${rowHeight * 0.15}px`, |
576 | | - left: `${xStart}px`, |
577 | | - width: `${xEnd - xStart}px`, |
578 | | - height: `${rowHeight * 0.7}px`, |
579 | | - zIndex: isDragging ? 3 : 2, |
580 | | - cursor: bar.ganttBarConfig.immobile ? '' : 'grab' |
581 | | - }" |
582 | | - @mousedown="onMouseEvent" |
583 | | - @click="onMouseEvent" |
584 | | - @mouseenter="handleBarMouseEnter" |
585 | | - @mouseleave="handleBarMouseLeave" |
586 | | - @contextmenu="onMouseEvent" |
587 | | - @touchstart="onTouchEvent" |
588 | | - @touchmove="onTouchEvent" |
589 | | - @touchend="onTouchEvent" |
590 | | - @touchcancel="onTouchEvent" |
591 | | - @keydown="onBarKeyDown" |
592 | | - @dblclick="startEditing" |
593 | | - role="listitem" |
594 | | - :aria-label="`Activity ${barConfig.label}`" |
595 | | - :aria-grabbed="isDragging" |
596 | | - tabindex="0" |
597 | | - :aria-describedby="`tooltip-${barConfig.id}`" |
598 | | - > |
| 566 | + <!-- Single root container for proper Vue 3 component structure --> |
| 567 | + <div class="g-gantt-bar-container" v-bind="$attrs"> |
| 568 | + <!-- Planned Bar (rendered as independent element) --> |
| 569 | + <div |
| 570 | + v-if="hasPlannedDates && !isGroupBar" |
| 571 | + :id="`${barConfig.id}-planned`" |
| 572 | + class="g-gantt-planned-bar" |
| 573 | + :style="plannedBarStyle" |
| 574 | + /> |
| 575 | + |
| 576 | + <!-- Main Bar --> |
| 577 | + <div |
| 578 | + :id="barConfig.id" |
| 579 | + :class="['g-gantt-bar', barConfig.class || '']" |
| 580 | + :style="{ |
| 581 | + ...barConfig.style, |
| 582 | + position: 'absolute', |
| 583 | + top: `${rowHeight * 0.15}px`, |
| 584 | + left: `${xStart}px`, |
| 585 | + width: `${xEnd - xStart}px`, |
| 586 | + height: `${rowHeight * 0.7}px`, |
| 587 | + zIndex: isDragging ? 3 : 2, |
| 588 | + cursor: bar.ganttBarConfig.immobile ? '' : 'grab' |
| 589 | + }" |
| 590 | + @mousedown="onMouseEvent" |
| 591 | + @click="onMouseEvent" |
| 592 | + @mouseenter="handleBarMouseEnter" |
| 593 | + @mouseleave="handleBarMouseLeave" |
| 594 | + @contextmenu="onMouseEvent" |
| 595 | + @touchstart="onTouchEvent" |
| 596 | + @touchmove="onTouchEvent" |
| 597 | + @touchend="onTouchEvent" |
| 598 | + @touchcancel="onTouchEvent" |
| 599 | + @keydown="onBarKeyDown" |
| 600 | + @dblclick="startEditing" |
| 601 | + role="listitem" |
| 602 | + :aria-label="`Activity ${barConfig.label}`" |
| 603 | + :aria-grabbed="isDragging" |
| 604 | + tabindex="0" |
| 605 | + :aria-describedby="`tooltip-${barConfig.id}`" |
| 606 | + > |
599 | 607 | <!-- Connection Points --> |
600 | 608 | <template v-if="enableConnectionCreation"> |
601 | 609 | <div |
@@ -681,10 +689,17 @@ onMounted(() => { |
681 | 689 | <div class="g-gantt-bar-handle-left" /> |
682 | 690 | <div class="g-gantt-bar-handle-right" /> |
683 | 691 | </template> |
| 692 | + </div> |
684 | 693 | </div> |
685 | 694 | </template> |
686 | 695 |
|
687 | 696 | <style> |
| 697 | +.g-gantt-bar-container { |
| 698 | + position: relative; |
| 699 | + width: 100%; |
| 700 | + height: 100%; |
| 701 | +} |
| 702 | +
|
688 | 703 | .g-gantt-bar { |
689 | 704 | display: flex; |
690 | 705 | justify-content: center; |
|
0 commit comments