Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

Keep the stages honest about a hidden list, focus and the grid's width

Guido Boyke6cc89a0b9611
diff --git a/app/assets/stylesheets/components/ticket_meeting_panel.css b/app/assets/stylesheets/components/ticket_meeting_panel.css
index c399a10..0731802 100644
--- a/app/assets/stylesheets/components/ticket_meeting_panel.css
+++ b/app/assets/stylesheets/components/ticket_meeting_panel.css
@@ -83,48 +83,53 @@
display: none;
}
-.layout[data-meeting-panel-stage="narrow"]:not(.hide-panel) > .column.panel {
- padding-top: 0;
-}
-
-.layout[data-meeting-panel-stage="narrow"]:not(.hide-panel) .ticket-meeting-panel__stage-tabs {
- position: sticky;
- top: 0;
- z-index: 1;
- display: flex;
- align-items: center;
- gap: 0.25rem;
- height: var(--meeting-panel-tabs-height);
- margin-bottom: 1rem;
- padding-right: 2rem;
- border-bottom: 1px solid rgb(var(--cream-200));
- background: rgb(var(--white));
- visibility: visible;
-}
-
-.ticket-meeting-panel__stage-tab {
- height: 2rem;
- padding: 0 0.75rem;
- border-radius: 0.375rem;
- font-size: 0.8125rem;
- font-weight: 500;
- color: rgb(var(--cream-700));
-}
-
-.ticket-meeting-panel__stage-tab:hover {
- background: rgb(var(--cream-100));
- color: rgb(var(--cream-900));
-}
-
-.ticket-meeting-panel__stage-tab[aria-selected="true"] {
- background: rgb(var(--cream-100));
- color: rgb(var(--cream-900));
- font-weight: 700;
- box-shadow: inset 0 -2px 0 rgb(var(--ink));
-}
-
-/* The lane's close button stays reachable while the ticket is in front. */
-.layout[data-meeting-panel-stage="narrow"][data-meeting-panel-tab="ticket"]:not(.hide-panel) > .column.panel .panel-close {
- visibility: visible;
- z-index: 2;
+/* Inside the same media query as layout.css's NARROW rules: below 1024px the ticket
+ page is the phone page, and a tab bar without the stage behind it would switch
+ nothing. */
+@media (min-width: 1024px) {
+ .layout[data-meeting-panel-stage="narrow"]:not(.hide-panel) > .column.panel {
+ padding-top: 0;
+ }
+
+ .layout[data-meeting-panel-stage="narrow"]:not(.hide-panel) .ticket-meeting-panel__stage-tabs {
+ position: sticky;
+ top: 0;
+ z-index: 1;
+ display: flex;
+ align-items: center;
+ gap: 0.25rem;
+ height: var(--meeting-panel-tabs-height);
+ margin-bottom: 1rem;
+ padding-right: 2rem;
+ border-bottom: 1px solid rgb(var(--cream-200));
+ background: rgb(var(--white));
+ visibility: visible;
+ }
+
+ .ticket-meeting-panel__stage-tab {
+ height: 2rem;
+ padding: 0 0.75rem;
+ border-radius: 0.375rem;
+ font-size: 0.8125rem;
+ font-weight: 500;
+ color: rgb(var(--cream-700));
+ }
+
+ .ticket-meeting-panel__stage-tab:hover {
+ background: rgb(var(--cream-100));
+ color: rgb(var(--cream-900));
+ }
+
+ .ticket-meeting-panel__stage-tab[aria-pressed="true"] {
+ background: rgb(var(--cream-100));
+ color: rgb(var(--cream-900));
+ font-weight: 700;
+ box-shadow: inset 0 -2px 0 rgb(var(--ink));
+ }
+
+ /* The lane's close button stays reachable while the ticket is in front. */
+ .layout[data-meeting-panel-stage="narrow"][data-meeting-panel-tab="ticket"]:not(.hide-panel) > .column.panel .panel-close {
+ visibility: visible;
+ z-index: 2;
+ }
}
diff --git a/app/assets/stylesheets/layout.css b/app/assets/stylesheets/layout.css
index 43d0c7b..ea1cdc3 100644
--- a/app/assets/stylesheets/layout.css
+++ b/app/assets/stylesheets/layout.css
@@ -21,7 +21,9 @@
width the assistant rule gives it), named once: the clamp below is built
from these, and lib/lane/meeting_panel_stage reads the same four from the
grid to decide how much fits (ticket_meeting_panel_controller), with
- --lane-gap above. */
+ --lane-gap above. ⚠️ In px (and a plain number for the share): the
+ controller reads them with parseFloat, and a custom property is not
+ resolved to px for it. A rem here would lay out right and decide wrong. */
--panel-min: 320px;
--panel-share: 0.34;
--panel-max: 480px;
@@ -1526,6 +1528,7 @@ main:has(.layout) > div {
assistant has taken the list's place, and not at the narrow one (two tracks,
no channel). */
.layout.two-column:not(.hide-content):not(.hide-panel):not([data-meeting-panel-stage="wide"]):not([data-meeting-panel-stage="narrow"]) > .column.content,
+ .layout.two-column.hide-list:not(.hide-content):not(.hide-panel):not([data-meeting-panel-stage="narrow"]) > .column.content,
body.assistant-panel-open .layout.two-column:not(.hide-content):not(.hide-panel):not([data-meeting-panel-stage="narrow"]) > .column.content {
margin-left: calc(-1 * var(--lane-gap));
}
@@ -1541,8 +1544,9 @@ main:has(.layout) > div {
minimums lane_split drags between. The handle stays hidden: it is drawn from
--list-split, a share of the WHOLE grid, and would stand beside the edge it
claims to move. Not while the assistant is open: it takes the list's place
- (L12) at any width. */
- body:not(.assistant-panel-open) .layout--lane.two-column:not(.hide-content):not(.hide-panel)[data-meeting-panel-stage="wide"] {
+ (L12) at any width. And not while the list is hidden on purpose
+ (.hide-list, the full-width detail): the track would stand empty. */
+ body:not(.assistant-panel-open) .layout--lane.two-column:not(.hide-content):not(.hide-panel):not(.hide-list)[data-meeting-panel-stage="wide"] {
grid-template-columns:
clamp(var(--list-min),
calc((100% - var(--panel-width) - 2 * var(--lane-gap)) * var(--list-share)),
diff --git a/app/javascript/controllers/lane_split_controller.js b/app/javascript/controllers/lane_split_controller.js
index f07887e..fd55d6c 100644
--- a/app/javascript/controllers/lane_split_controller.js
+++ b/app/javascript/controllers/lane_split_controller.js
@@ -32,15 +32,18 @@ export default class extends Controller {
// between the same two minimums the drag is held between.
this.element.style.setProperty("--list-min", `${MIN_LIST_PX}px`)
this.element.style.setProperty("--lane-min", `${MIN_LANE_PX}px`)
- this.onWindowResize = this.onWindowResize.bind(this)
this.onPointerMove = this.onPointerMove.bind(this)
this.onPointerUp = this.onPointerUp.bind(this)
- window.addEventListener("resize", this.onWindowResize)
this.apply(this.storedShare)
+ // The GRID's width, not the window's: the assistant beside the page narrows
+ // and widens the grid with the window unchanged, and a split re-measured only
+ // on window resize kept the pixels the narrower grid had allowed.
+ this.resizeObserver = new ResizeObserver(() => this.onGridResize())
+ this.resizeObserver.observe(this.element)
}
disconnect() {
- window.removeEventListener("resize", this.onWindowResize)
+ this.resizeObserver?.disconnect()
this.stopDragging()
}
@@ -95,7 +98,7 @@ export default class extends Controller {
this.handleTarget.setAttribute("aria-valuenow", String(Math.round((px / this.gridWidth) * 100)))
}
- onWindowResize() {
+ onGridResize() {
// The remembered SHARE, re-measured - not the pixels currently set. Reading
// the pixels back would ratchet the list smaller on every resize, because
// each clamp would become the new remembered width.
diff --git a/app/javascript/controllers/ticket_meeting_panel_controller.js b/app/javascript/controllers/ticket_meeting_panel_controller.js
index 14b974a..6e825d7 100644
--- a/app/javascript/controllers/ticket_meeting_panel_controller.js
+++ b/app/javascript/controllers/ticket_meeting_panel_controller.js
@@ -27,10 +27,21 @@ export default class extends Controller {
connect() {
this.grid = this.element.closest(".layout")
if (this.grid) {
+ // Read once: they are the stylesheet's constants (layout.css, :root, in px),
+ // and the observer below can fire on every frame of the assistant's drag.
+ const style = getComputedStyle(this.grid)
+ const number = name => parseFloat(style.getPropertyValue(name))
+ this.panelNumbers = {
+ panelMin: number("--panel-min"),
+ panelShare: number("--panel-share"),
+ panelMax: number("--panel-max"),
+ gap: number("--lane-gap")
+ }
// Before the lane opens, so its first frame already has the right stage.
this.select("meeting")
- this.updateStage()
- this.resizeObserver = new ResizeObserver(() => this.updateStage())
+ this.updateStage(this.grid.getBoundingClientRect().width)
+ this.resizeObserver = new ResizeObserver(([entry]) =>
+ this.updateStage(entry.borderBoxSize?.[0]?.inlineSize ?? entry.contentRect.width))
this.resizeObserver.observe(this.grid)
}
@@ -57,22 +68,23 @@ export default class extends Controller {
// --- stages (S2) --------------------------------------------------------
- updateStage() {
- const style = getComputedStyle(this.grid)
- const number = name => parseFloat(style.getPropertyValue(name))
- const stage = meetingPanelStage({
- gridWidth: this.grid.getBoundingClientRect().width,
- panelMin: number("--panel-min"),
- panelShare: number("--panel-share"),
- panelMax: number("--panel-max"),
- gap: number("--lane-gap")
- })
+ updateStage(gridWidth) {
+ const stage = meetingPanelStage({ gridWidth, ...this.panelNumbers })
const previous = this.grid.dataset.meetingPanelStage
if (stage === previous) return
this.grid.dataset.meetingPanelStage = stage
// Dropping to the tabs shows the meeting first: it is what was opened last (F6).
- if (stage === "narrow") this.select("meeting")
+ // Unless the panel was already open and somebody is working in the ticket (the
+ // focus is in it): the grid narrows under their hands (a window or the assistant
+ // dragged), and hiding the field they type into would send the next keys
+ // nowhere. Not on opening: the link just clicked sits in the ticket, too.
+ if (stage === "narrow") this.select(previous && this.ticketHasFocus() ? "ticket" : "meeting")
+ }
+
+ ticketHasFocus() {
+ const active = document.activeElement
+ return Boolean(active && active !== document.body && this.grid.querySelector(":scope > .column.content")?.contains(active))
}
showTicket() {
@@ -87,8 +99,8 @@ export default class extends Controller {
if (!this.grid) return
this.grid.dataset.meetingPanelTab = tab
- if (this.hasTicketTabTarget) this.ticketTabTarget.setAttribute("aria-selected", String(tab === "ticket"))
- if (this.hasMeetingTabTarget) this.meetingTabTarget.setAttribute("aria-selected", String(tab === "meeting"))
+ if (this.hasTicketTabTarget) this.ticketTabTarget.setAttribute("aria-pressed", String(tab === "ticket"))
+ if (this.hasMeetingTabTarget) this.meetingTabTarget.setAttribute("aria-pressed", String(tab === "meeting"))
}
// While the lane shows this panel, the next Escape closes it.
diff --git a/app/views/organisations/ticket_meeting_panels/unavailable.html.erb b/app/views/organisations/ticket_meeting_panels/unavailable.html.erb
index dd718db..56bde6f 100644
--- a/app/views/organisations/ticket_meeting_panels/unavailable.html.erb
+++ b/app/views/organisations/ticket_meeting_panels/unavailable.html.erb
@@ -1,8 +1,12 @@
<%# One answer for a project, ticket or meeting that is missing, not readable or of another
- organisation: it names none of them. %>
+ organisation: it names none of them, also not in its tabs (plain labels: a number or a
+ date would tell which part was there). %>
<%= turbo_frame_tag Organisations::TicketMeetingPanelsController::FRAME_ID do %>
<div class="ticket-meeting-panel" data-controller="ticket-meeting-panel"
data-ticket-meeting-panel-ticket-id-value="<%= params[:ticket_id].to_s %>">
+ <%= render 'organisations/tickets/meeting_panel_stage_tabs',
+ ticket_label: t('views.organisations.tickets.meeting_panel.ticket_tab_plain'),
+ meeting_label: t('views.organisations.tickets.meeting_panel.meeting_tab_plain') %>
<p class="ticket-meeting-panel__empty"><%= t('views.organisations.tickets.meeting_panel.unavailable') %></p>
</div>
<% end %>
diff --git a/app/views/organisations/tickets/_meeting_panel.html.erb b/app/views/organisations/tickets/_meeting_panel.html.erb
index 2abd467..086ddfb 100644
--- a/app/views/organisations/tickets/_meeting_panel.html.erb
+++ b/app/views/organisations/tickets/_meeting_panel.html.erb
@@ -12,19 +12,9 @@
<div class="ticket-meeting-panel"
data-controller="ticket-meeting-panel"
data-ticket-meeting-panel-ticket-id-value="<%= ticket.id %>">
- <%# The narrow stage (S2): ticket and meeting as two tabs in one column. Hidden at the
- other stages (components/ticket_meeting_panel.css); the controller keeps the
- selection on the grid and in aria-selected. %>
- <div class="ticket-meeting-panel__stage-tabs" role="tablist" aria-label="<%= t("#{mp}.stage_tabs_label") %>">
- <button type="button" role="tab" class="ticket-meeting-panel__stage-tab" aria-selected="false"
- data-ticket-meeting-panel-target="ticketTab" data-action="ticket-meeting-panel#showTicket">
- <%= t("#{mp}.ticket_tab", number: ticket.number) %>
- </button>
- <button type="button" role="tab" class="ticket-meeting-panel__stage-tab" aria-selected="true"
- data-ticket-meeting-panel-target="meetingTab" data-action="ticket-meeting-panel#showMeeting">
- <%= t("#{mp}.meeting_tab", date: l(meeting.occurred_at.to_date, format: :short)) %>
- </button>
- </div>
+ <%= render 'organisations/tickets/meeting_panel_stage_tabs',
+ ticket_label: t("#{mp}.ticket_tab", number: ticket.number),
+ meeting_label: t("#{mp}.meeting_tab", date: l(meeting.occurred_at.to_date, format: :short)) %>
<header class="ticket-meeting-panel__head">
<p class="text-xs font-mono uppercase tracking-wider text-cream-600"><%= t("#{mp}.eyebrow") %></p>
<% if meetings.size > 1 %>
diff --git a/app/views/organisations/tickets/_meeting_panel_stage_tabs.html.erb b/app/views/organisations/tickets/_meeting_panel_stage_tabs.html.erb
new file mode 100644
index 0000000..8026c2a
--- /dev/null
+++ b/app/views/organisations/tickets/_meeting_panel_stage_tabs.html.erb
@@ -0,0 +1,18 @@
+<%# locals: (ticket_label:, meeting_label:) %>
+<%# The narrow stage (doc/ticket_meeting_panel_plan.md, S2): ticket and meeting as two tabs
+ in one column, the way back to the ticket in both answers of the panel (the meeting,
+ and "not available"). Hidden at the other stages (components/ticket_meeting_panel.css).
+ Two buttons that say which one is in front (aria-pressed), not an ARIA tab widget:
+ the two columns are not tab panels of this bar, and a half-built tablist promises
+ arrow keys it does not have. ticket_meeting_panel_controller keeps the state. %>
+<div class="ticket-meeting-panel__stage-tabs" role="group"
+ aria-label="<%= t('views.organisations.tickets.meeting_panel.stage_tabs_label') %>">
+ <button type="button" class="ticket-meeting-panel__stage-tab" aria-pressed="false"
+ data-ticket-meeting-panel-target="ticketTab" data-action="ticket-meeting-panel#showTicket">
+ <%= ticket_label %>
+ </button>
+ <button type="button" class="ticket-meeting-panel__stage-tab" aria-pressed="true"
+ data-ticket-meeting-panel-target="meetingTab" data-action="ticket-meeting-panel#showMeeting">
+ <%= meeting_label %>
+ </button>
+</div>
diff --git a/config/locales/views/tickets.de.yml b/config/locales/views/tickets.de.yml
index 1f337a7..3d0e441 100644
--- a/config/locales/views/tickets.de.yml
+++ b/config/locales/views/tickets.de.yml
@@ -238,6 +238,8 @@ de:
stage_tabs_label: Ticket oder Meeting zeigen
ticket_tab: "Ticket #%{number}"
meeting_tab: "Meeting %{date}"
+ ticket_tab_plain: Ticket
+ meeting_tab_plain: Meeting
shared:
subtasks:
heading: Unteraufgaben
diff --git a/config/locales/views/tickets.en.yml b/config/locales/views/tickets.en.yml
index 1907f35..46452c1 100644
--- a/config/locales/views/tickets.en.yml
+++ b/config/locales/views/tickets.en.yml
@@ -238,6 +238,8 @@ en:
stage_tabs_label: Show the ticket or the meeting
ticket_tab: "Ticket #%{number}"
meeting_tab: "Meeting %{date}"
+ ticket_tab_plain: Ticket
+ meeting_tab_plain: Meeting
shared:
subtasks:
heading: Sub-tasks
diff --git a/spec/system/ticket_meeting_panel_stages_spec.rb b/spec/system/ticket_meeting_panel_stages_spec.rb
index e38075a..3dd650c 100644
--- a/spec/system/ticket_meeting_panel_stages_spec.rb
+++ b/spec/system/ticket_meeting_panel_stages_spec.rb
@@ -46,6 +46,13 @@ RSpec.describe 'Meeting beside the ticket, by the width of the grid', type: :sys
end
after do
+ # The window is reused by the next example, and with it this origin's storage: a
+ # hidden list or a remembered split must not travel.
+ begin
+ page.execute_script('sessionStorage.clear(); localStorage.clear()')
+ rescue StandardError
+ nil
+ end
page.driver.browser.manage.window.resize_to(1440, 900)
ActsAsTenant.current_tenant = nil
Prosopite.resume
@@ -82,9 +89,21 @@ RSpec.describe 'Meeting beside the ticket, by the width of the grid', type: :sys
def assistant_open? = page.evaluate_script('document.body.classList.contains("assistant-panel-open")')
- # Wait for the grid's transition to settle before measuring.
+ # Measure only a grid at rest: its tracks animate (layout.css), and while the
+ # assistant opens or closes the grid's width changes over several frames, each of
+ # which re-sets the split and restarts that animation. A fixed sleep measured one
+ # of those frames.
def settled
- sleep 0.5
+ probe = "(() => { const g = document.querySelector('.layout'); " \
+ 'return [g.getAnimations().length, Math.round(g.getBoundingClientRect().width)] })()'
+ previous = nil
+ 40.times do
+ state = page.evaluate_script(probe)
+ break if state.first.zero? && state == previous
+
+ previous = state
+ sleep 0.1
+ end
end
context 'without the assistant' do
@@ -119,13 +138,13 @@ RSpec.describe 'Meeting beside the ticket, by the width of the grid', type: :sys
expect(widths[:ticket]).to eq(width('.layout'))
expect(widths[:meeting]).to eq(width('.layout'))
# The meeting first: it was opened last (F6).
- expect(stage_tab('Meeting')['aria-selected']).to eq('true')
+ expect(stage_tab('Meeting')['aria-pressed']).to eq('true')
expect(page).to have_css('aside.column.panel h2', text: 'Planning call', visible: :visible)
expect(page).to have_no_css("#ticket-content-#{ticket.id}", visible: :visible)
scroll('.layout .column.panel', to: 900)
stage_tab("Ticket ##{ticket.number}").click
- expect(stage_tab("Ticket ##{ticket.number}")['aria-selected']).to eq('true')
+ expect(stage_tab("Ticket ##{ticket.number}")['aria-pressed']).to eq('true')
expect(page).to have_css("#ticket-content-#{ticket.id}", visible: :visible)
expect(page).to have_no_css('aside.column.panel h2', visible: :visible)
# The tab bar stays, so there is a way back.
@@ -140,6 +159,70 @@ RSpec.describe 'Meeting beside the ticket, by the width of the grid', type: :sys
expect(page).to have_css("#ticket-content-#{ticket.id}", visible: :visible)
expect(scroll_top('.layout .column.content')).to be_within(2).of(700)
end
+
+ it 'keeps a hidden list hidden at the wide stage, with no channel before the ticket' do
+ page.driver.browser.manage.window.resize_to(1600, 900)
+ visit organisation_project_tickets_path(organisation, project)
+ page.execute_script("sessionStorage.setItem('layoutState', JSON.stringify({ categories: false, list: false, content: true, panel: false }))")
+ visit organisation_project_tickets_path(organisation, project, ticket_id: ticket.id)
+ expect(page).to have_css('.layout.hide-list')
+ open_panel
+
+ expect(page).to have_css('.layout[data-meeting-panel-stage="wide"]')
+ settled
+ expect(widths[:list]).to eq(0)
+ expect(page.evaluate_script("document.querySelector('.layout .column.content').getBoundingClientRect().left"))
+ .to be_within(1).of(page.evaluate_script("document.querySelector('.layout').getBoundingClientRect().left"))
+ end
+
+ it 'offers the way back to the ticket when the meeting is not available on a narrow grid' do
+ page.driver.browser.manage.window.resize_to(1024, 900)
+ visit organisation_project_tickets_path(organisation, project, ticket_id: ticket.id)
+ expect(page).to have_css("#ticket-content-#{ticket.id}")
+ url = organisation_project_ticket_meeting_panel_path(organisation, project, ticket, meeting_id: SecureRandom.uuid)
+ page.execute_script("document.getElementById('ticket_meeting_panel').src = #{url.to_json}")
+
+ expect(page).to have_css('.layout[data-meeting-panel-stage="narrow"]:not(.hide-panel)')
+ expect(page).to have_text(I18n.t('views.organisations.tickets.meeting_panel.unavailable'))
+ stage_tab('Ticket').click
+ expect(page).to have_css("#ticket-content-#{ticket.id}", visible: :visible)
+ end
+
+ it 'keeps the ticket in front when the grid narrows while the ticket has the focus' do
+ open_at(1200)
+ expect(page).to have_css('.layout[data-meeting-panel-stage="medium"]')
+ page.execute_script("document.querySelector('#ticket-header a[href], #ticket-header button').focus()")
+ focused = page.evaluate_script('document.activeElement.outerHTML')
+
+ page.driver.browser.manage.window.resize_to(1024, 900)
+
+ expect(page).to have_css('.layout[data-meeting-panel-stage="narrow"]')
+ expect(stage_tab("Ticket ##{ticket.number}")['aria-pressed']).to eq('true')
+ expect(page).to have_css("#ticket-content-#{ticket.id}", visible: :visible)
+ expect(page.evaluate_script('document.activeElement.outerHTML')).to eq(focused)
+ end
+ end
+
+ # The split follows the GRID's width as well: the assistant changes it without the
+ # window changing. Before, the split was computed from the window's resize only, and a
+ # list remembered at 70 % came back at whatever the narrower grid had allowed.
+ context 'the split between list and lane' do
+ it 'takes its remembered share of the grid again when the assistant closes' do
+ page.driver.browser.manage.window.resize_to(1600, 900)
+ visit organisation_project_tickets_path(organisation, project, ticket_id: ticket.id)
+ page.execute_script("localStorage.setItem('lalabase:lane-split:tickets', '0.7')")
+ find('#assistant-panel-trigger').click
+ expect(page).to have_css('body.assistant-panel-open')
+ visit organisation_project_tickets_path(organisation, project, ticket_id: ticket.id)
+ expect(page).to have_css('body.assistant-panel-open')
+
+ find('#assistant-panel-trigger').click
+ expect(page).to have_no_css('body.assistant-panel-open')
+ settled
+
+ grid = width('.layout')
+ expect(widths[:list]).to be_within(2).of((grid * 0.7).round)
+ end
end
context 'with the assistant' do
@@ -170,7 +253,7 @@ RSpec.describe 'Meeting beside the ticket, by the width of the grid', type: :sys
expect(page).to have_css('.layout[data-meeting-panel-stage="narrow"]')
expect(page).to have_css('.ticket-meeting-panel__stage-tabs', visible: :visible)
- expect(stage_tab('Meeting')['aria-selected']).to eq('true')
+ expect(stage_tab('Meeting')['aria-pressed']).to eq('true')
expect(assistant_open?).to be(true)
end
end