From d2ab8e64822971d9d63aff203b6566a5700cd194 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Wed, 21 Jan 2026 14:33:31 +0100 Subject: [PATCH] refactor(schedule): consolidate scrollbars onto single parent element - Move horizontal scroll control to parent .scroll-wrapper element - Both vertical and horizontal scrollbars now on same container - Pass isHorizontalScrollMode as input to schedule-week component - Remove duplicate scroll wrapper from schedule-week - Maintain responsive column widths based on scroll mode - Fixes scrollbar positioning and coordination issues This ensures both scrollbars are managed by the same element, providing better UX and preventing scrollbar positioning conflicts. --- .../schedule-week.component.html | 366 +++++++++--------- .../schedule-week.component.scss | 27 -- .../schedule-week/schedule-week.component.ts | 20 +- .../schedule/schedule/schedule.component.html | 6 +- .../schedule/schedule/schedule.component.scss | 28 ++ .../schedule/schedule/schedule.component.ts | 10 + 6 files changed, 227 insertions(+), 230 deletions(-) diff --git a/src/app/features/schedule/schedule-week/schedule-week.component.html b/src/app/features/schedule/schedule-week/schedule-week.component.html index 894310b04..df34f0f2c 100644 --- a/src/app/features/schedule/schedule-week/schedule-week.component.html +++ b/src/app/features/schedule/schedule-week/schedule-week.component.html @@ -1,191 +1,189 @@ -
-
-
-
- @for (day of daysToShow(); track $index) { -
- @if (day === todayDateStr()) { - wb_sunny - } -
{{ day | localeDate: 'd' }}
-
{{ day | localeDate: 'EEE' }}
-
- } -
-
- -
- - @for (time of times(); track $index) { -
- {{ time }} -
- } - - - @for (row of rowsByNr; track $index) { -
- } - - +
+
+
@for (day of daysToShow(); track $index) { -
-
- } - - - @if (workStartEnd()) { -
-
{{ T.F.SCHEDULE.START | translate }}
-
-
-
{{ T.F.SCHEDULE.END | translate }}
-
- } - - @if (currentTimeRow() !== null) { -
-
-
- } - - - @for (ev of safeEvents(); track ev.id) { - @if (isDraggableSE(ev)) { - - } @else { - - } - } - - - @for (beyondBudgetDay of safeBeyondBudget(); track i; let i = $index) { - @if (beyondBudgetDay.length > 0) { -
-
- hourglass_disabled - {{ beyondBudgetDay.length }} -
- @for (ev of beyondBudgetDay; track ev.id) { - @if (isDraggableSE(ev)) { - - } @else { - - } - } -
- } - } - - @if ( - (!isTaskDragActive() || isCtrlPressed()) && newTaskPlaceholder(); - as newTaskPlaceholder - ) { - - - } - - @if (isDragging() && currentDragEvent() && dragPreviewStyle()) { - - @if (dragPreviewLabel()) { -
- {{ dragPreviewLabel() }} -
+
+ @if (day === todayDateStr()) { + wb_sunny } - +
{{ day | localeDate: 'd' }}
+
{{ day | localeDate: 'EEE' }}
+
}
+
+ +
+ + @for (time of times(); track $index) { +
+ {{ time }} +
+ } + + + @for (row of rowsByNr; track $index) { +
+ } + + + @for (day of daysToShow(); track $index) { +
+
+ } + + + @if (workStartEnd()) { +
+
{{ T.F.SCHEDULE.START | translate }}
+
+
+
{{ T.F.SCHEDULE.END | translate }}
+
+ } + + @if (currentTimeRow() !== null) { +
+
+
+ } + + + @for (ev of safeEvents(); track ev.id) { + @if (isDraggableSE(ev)) { + + } @else { + + } + } + + + @for (beyondBudgetDay of safeBeyondBudget(); track i; let i = $index) { + @if (beyondBudgetDay.length > 0) { +
+
+ hourglass_disabled + {{ beyondBudgetDay.length }} +
+ @for (ev of beyondBudgetDay; track ev.id) { + @if (isDraggableSE(ev)) { + + } @else { + + } + } +
+ } + } + + @if ( + (!isTaskDragActive() || isCtrlPressed()) && newTaskPlaceholder(); + as newTaskPlaceholder + ) { + + + } + + @if (isDragging() && currentDragEvent() && dragPreviewStyle()) { + + @if (dragPreviewLabel()) { +
+ {{ dragPreviewLabel() }} +
+ } +
+ }
@if (showShiftKeyInfo()) { diff --git a/src/app/features/schedule/schedule-week/schedule-week.component.scss b/src/app/features/schedule/schedule-week/schedule-week.component.scss index 74731e8a9..766f16e58 100644 --- a/src/app/features/schedule/schedule-week/schedule-week.component.scss +++ b/src/app/features/schedule/schedule-week/schedule-week.component.scss @@ -18,33 +18,6 @@ // Enable horizontal scroll when viewport is too small for 7 days &[data-horizontal-scroll] { - .horizontal-scroll-wrapper { - overflow-x: scroll; // Always show horizontal scrollbar - overflow-y: visible; // Allow vertical content to extend - - // Match app's standard scrollbar styling - scrollbar-width: 4px; - scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track); - - &::-webkit-scrollbar { - height: 8px; // Slightly taller than standard for horizontal - } - - &::-webkit-scrollbar-track { - background: var(--scrollbar-track); - border-radius: 4px; - } - - &::-webkit-scrollbar-thumb { - background: var(--scrollbar-thumb); - border-radius: 16px; - - &:hover { - background: var(--scrollbar-thumb-hover); - } - } - } - .week-header { // Remove left/right constraints to allow horizontal scrolling left: auto; diff --git a/src/app/features/schedule/schedule-week/schedule-week.component.ts b/src/app/features/schedule/schedule-week/schedule-week.component.ts index 5cf1e50df..79a58a9b2 100644 --- a/src/app/features/schedule/schedule-week/schedule-week.component.ts +++ b/src/app/features/schedule/schedule-week/schedule-week.component.ts @@ -33,9 +33,6 @@ import { formatMonthDay } from '../../../util/format-month-day.util'; import { ScheduleWeekDragService } from './schedule-week-drag.service'; import { calculatePlaceholderForGridMove } from './schedule-week-placeholder.util'; import { truncate } from '../../../util/truncate'; -import { fromEvent } from 'rxjs'; -import { debounceTime, map, startWith } from 'rxjs/operators'; -import { toSignal } from '@angular/core/rxjs-interop'; const D_HOURS = 24; @@ -61,7 +58,7 @@ const D_HOURS = 24; '[class.is-not-dragging]': '!isDragging()', '[class.is-resizing-event]': 'isAnyEventResizing()', '[class]': 'dragEventTypeClass()', - '[attr.data-horizontal-scroll]': 'shouldEnableHorizontalScroll()', + '[attr.data-horizontal-scroll]': 'isHorizontalScrollMode() || null', }, }) export class ScheduleWeekComponent implements OnInit, AfterViewInit, OnDestroy { @@ -69,21 +66,8 @@ export class ScheduleWeekComponent implements OnInit, AfterViewInit, OnDestroy { private _dateTimeFormatService = inject(DateTimeFormatService); private _translateService = inject(TranslateService); - private _windowSize = toSignal( - fromEvent(window, 'resize').pipe( - startWith({ width: window.innerWidth }), - debounceTime(50), - map(() => ({ width: window.innerWidth })), - ), - { initialValue: { width: window.innerWidth } }, - ); - - shouldEnableHorizontalScroll = computed(() => { - // Enable scroll when viewport is smaller than what's needed for 7 days - return this._windowSize().width < 1900; - }); - isInPanel = input(false); + isHorizontalScrollMode = input(false); events = input([]); beyondBudget = input([]); daysToShow = input([]); diff --git a/src/app/features/schedule/schedule/schedule.component.html b/src/app/features/schedule/schedule/schedule.component.html index 29d16ac40..29d615dd8 100644 --- a/src/app/features/schedule/schedule/schedule.component.html +++ b/src/app/features/schedule/schedule/schedule.component.html @@ -30,7 +30,10 @@
-
+
@if (isMonthView()) { }
diff --git a/src/app/features/schedule/schedule/schedule.component.scss b/src/app/features/schedule/schedule/schedule.component.scss index 8b5e2ba5b..c980903e3 100644 --- a/src/app/features/schedule/schedule/schedule.component.scss +++ b/src/app/features/schedule/schedule/schedule.component.scss @@ -15,6 +15,34 @@ overflow-y: scroll; overflow-x: hidden; box-sizing: border-box; + + // Enable horizontal scroll when viewport is too small for 7 days + &[data-horizontal-scroll] { + overflow-x: scroll; // Show horizontal scrollbar when needed + + // Match app's standard scrollbar styling + scrollbar-width: 4px; + scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track); + + &::-webkit-scrollbar { + width: 4px; + height: 8px; // Slightly taller for horizontal visibility + } + + &::-webkit-scrollbar-track { + background: var(--scrollbar-track); + border-radius: 4px; + } + + &::-webkit-scrollbar-thumb { + background: var(--scrollbar-thumb); + border-radius: 16px; + + &:hover { + background: var(--scrollbar-thumb-hover); + } + } + } } header { diff --git a/src/app/features/schedule/schedule/schedule.component.ts b/src/app/features/schedule/schedule/schedule.component.ts index 4567da7e7..214afbe02 100644 --- a/src/app/features/schedule/schedule/schedule.component.ts +++ b/src/app/features/schedule/schedule/schedule.component.ts @@ -89,6 +89,16 @@ export class ScheduleComponent { { initialValue: { width: window.innerWidth, height: window.innerHeight } }, ); + shouldEnableHorizontalScroll = computed(() => { + const selectedView = this._currentTimeViewMode(); + // Only enable horizontal scroll for week view when viewport is narrow + if (selectedView !== 'week') { + return false; + } + // Enable scroll when viewport is smaller than what's needed for 7 days + return this._windowSize().width < 1900; + }); + private _daysToShowCount = computed(() => { const size = this._windowSize(); const selectedView = this._currentTimeViewMode();