Repository navigation
Issue 226 Note Image Could Not Be Closed
Reported: #226 by Dr4inder, October 2026 Β· Module: Tickets Β· Present in: every version since files on notes arrived (discussion #69) Β· Fixed in: 4.4.0
Open a ticket, click a picture attached to one of its notes, and the picture fills the browser. There is no close button, Escape does nothing, and the browser's Back button leaves the ticket rather than returning to the note.
A file on a note was drawn as a plain link to the document download address:
const href = '../api/documents/download.php?id=' + encodeURIComponent(d.id);
return `<a class="note-file" href="${escapeHtml(href)}" ...>`;No target, no click handler. For most files that is fine - the server sends them as a download, and the page stays where it is. A picture is different: a picture is safe to show in the browser, so the server sends it to be shown, not saved. The link then did what any link does - it navigated the whole Tickets page away and replaced it with the bare image.
That explains all three symptoms at once:
- No close button - there is no page any more, only the browser's own image display.
- Escape does nothing - the browser's image display has no Escape action.
- Back leaves the ticket - the Tickets page opens a ticket without changing the address, so the history entry before the picture is the inbox, not the ticket.
π Email attachments never had this problem, because they open with
window.open(..., '_blank')- a new tab. The note files, added later, used a different pattern. It was the only link todownload.phpanywhere in the app.
The one-line fix was target="_blank", the same as email attachments. It stops the page being replaced, but it is not what was asked for: the picture lands in another tab, with the ticket out of sight, and "close" means closing a tab. The reporter asked for a close control and Escape.
What was built instead: the picture opens in a floating window over the ticket, the same one the Files module uses - drag it, resize it from any edge or corner, snap it, maximise it, zoom, download, close with Γ or Escape.
Files already had a window that does all of that, and a viewer that shows pictures, PDFs and Office files. But neither could simply be loaded on the Tickets page:
-
The window manager (
files-wm.js) reached for Files-only parts as soon as it loaded - the desktop area, the taskbar, the hover previews, the auto-hiding navbar. On the Tickets page those do not exist. -
The viewer (
files-viewer.js) fetched its file through Files' own access tokens. A note's file is a different kind of document, with its own permission check.
So the window was split in two:
-
assets/js/float-window.js- the window itself: drag, resize, snap, maximise, focus. Works on any page.FloatWin.page()gives an ordinary page its own window layer; Escape closes the window in front. -
files-wm.jskeeps the desktop half (taskbar, minimise, previews, menus) and builds on the shared window through hooks. The Files desktop behaves exactly as before. -
The viewer gained
FilesViewer.openUrl(): open a file from an address the caller already has. Tickets passes the note file's owndownload.phpaddress, so the permission check is the same one the link always had.
Details for developers: Floating windows and the file viewer.
-
The Download button - the viewer's Download made a link to the same address, which serves a picture to show. Without the
downloadattribute it would have opened the picture in the tab - the very bug being fixed.openUrlsets it. - Escape - the window takes focus when it opens, so Escape works straight away. But Escape on a page full of text boxes is also "cancel what I'm typing", so a window is left alone while the person is typing in a field elsewhere on the page.
- Ctrl-click and middle-click still open the picture in a new tab - the link stays a real link, and only a plain click is intercepted.
- SVG is not opened in the viewer - it can carry script. It stays a plain link.
- Phones get the Files phone viewer: full screen, with Back.
| File | Change |
|---|---|
π© assets/js/float-window.js
|
new - the window, moved out of files-wm.js
|
π© assets/css/float-window.css
|
new - the window and viewer styles, moved out of files.css unchanged |
π¦ assets/js/files-wm.js
|
builds on the shared window; taskbar via hooks |
π¦ assets/js/files-viewer.js
|
openUrl(); works without FILES_BOOT / FilesWM
|
π¦ assets/js/inbox.js
|
a click on a note's picture opens it in the viewer |
π¦ assets/css/mobile.css
|
the phone viewer is no longer Files-only |
π¨ tickets/index.php, files/index.php
|
load the shared files; Tickets exports only the viewer's strings |
In headless Chrome, signed in, against a real ticket with a picture on a note:
| Check | Result |
|---|---|
| Click the picture | a window opens over the ticket; the page address does not change |
| The picture | loaded, fitted to the window (52%), zoom and fit buttons present |
| Maximise, then restore | fills the screen, then back to its size |
| Drag the title bar 150, 100 | moved 150, 100 |
| Drag the bottom-right corner in 200, 100 | shrank 200, 100 |
| Download | a link to the same address with download set to the file name |
| Click the same picture again | the window comes to the front - still one window |
| Ctrl-click | left to the browser (new tab) |
| Escape | the window closes |
| Phone width (390px) | full-screen viewer with Back; Back closes it |
The control: with the old inbox.js the same test fails - there is no picture link to open.
Files, re-checked - because its window code moved: a window opens with its taskbar button; minimise, restore from the taskbar, a taskbar click on the front window minimises it; renaming a window renames its button; maximise reports the geometry for saving; focus moves between two windows' buttons; closing removes the button; the viewer opens a real picture from Files.
- Drag, resize and snap with a real mouse. The test drove them with synthetic pointer events, which exercise the same code - but nobody has yet dragged one by hand on the Tickets page.
-
The other viewer kinds on Tickets (PDF, Word, spreadsheets) -
openUrlcan show them, but Tickets only uses it for pictures, as asked.
Asked for straight after the first fix:
-
Pictures attached to emails open the same way. The ticket's Attachments list - its thumbnails, its rows, and the phone's attachment cards - used
window.open(..., '_blank').openAttachment()now looks the attachment up, and a picture goes toFilesViewer.openUrl()with the sameget_attachment.phpaddress (same permission check); anything else still opens a new tab. The window opens above the Attachments list, and Escape closes the window, not the list. - The picture refits as the window is resized, as a PDF already did - until you zoom in or out yourself; Fit hands it back. This changes the Files viewer too: Files said pictures kept fitting, and until now they did not.
The obvious code - a ResizeObserver on the stage that resizes the picture inside its callback - logged "ResizeObserver loop completed with undelivered notifications". Resizing the picture adds or removes the stage's scrollbars, which resizes the stage again inside the same callback; the browser drops the notifications it cannot deliver, and the dropped ones were real window resizes that never refitted. The refit now runs just after the callback (a 16ms timer, as the PDF view uses 120ms), never inside it.
Headless Chrome with a virtual clock (--virtual-time-budget) does not lay the page out between script steps, so a resize observer fires or not depending on whether the test happens to read a size. The same build passed, failed, and half-passed on three runs. It was re-run in real time - headless Chrome kept alive with --remote-debugging-port and stopped after 40 seconds, reading the console live:
| Step | Picture width |
|---|---|
| Opened in an 820 Γ 600 window | 652px (16%) |
| Window shrunk to 500 Γ 400 | 385px |
| Maximised | 1055px |
| Restored | 385px |
| Zoom in, then resize | 482px β 482px - left alone |
| Fit, then resize | 719px β 452px - refitting again |
Control: the same run with the previous viewer - 632px at every step.
Also checked: a thumbnail and a row each open a window (no new tab); a second picture opens a second window in front; Escape closes the front window and leaves the Attachments list open; a PDF attachment still opens a new tab.
Ed then asked for PDFs as well. One list in inbox.js, VIEWER_FILE_RE, says what Tickets sends to the viewer - pictures and PDFs - for both note files and email attachments. The viewer can show more (Word, spreadsheets, text, zips); those were left as downloads by choice, and zips would need a guard first, because opening something inside a zip writes to Files' audit log by Files id.
The trap it found: outside Files the viewer's base path was '../'. pdf.js loads with import(), and import() resolves a relative path against the script's address (assets/js/), not the page's - so it would have looked in assets/assets/js/vendor/. Pictures never noticed, because an <img> resolves against the page. The base is now worked out from the viewer's own script URL when Files is not there to supply BASE_URL.
Proved in real time on two real tickets: a 12-page PDF on a note and a 2-page PDF emailed in each open in a window (no new tab), draw their pages, show "1 of 12" / "1 of 2" and zoom, and the note's PDF refits when the window shrinks (page 762px β 502px). The note's picture still opens beside it. No errors.
- After upgrading to 4.4.0, hard-refresh (Ctrl-F5). Clicking a picture or PDF on a note, or in a ticket's Attachments list, opens it over the ticket.
- Before 4.4.0, Ctrl-click (or middle-click) a picture to open it in a new tab, which leaves the ticket where it is.
FreeITSM β an open-source IT Service Management platform Β· github.com/edmozley/freeitsm Β· MIT licence
- Installation
- β° Scheduled tasks (cron jobs)
-
Architecture
- β³ π§Ή Root folder tidy (URL routing)
- β³ π Database Integrity (FKs & constraints)
- β³ π οΈ Database Verification β Developer Guide
- β³ π§© Service Layer (UI + API share code)
- β³ πͺ€ Code traps (the TRAP: comments)
- β³ π Commenting for the Engineering wiki
- β³ π οΈ Engineering wiki scanner - Developer Guide
- β³ π Service-Layer progress
- π€ Contributing (read before a pull request)
- π§ͺ Developer tests
- AI Providers
- Internationalisation (i18n)
- Timezones & Time Handling
- π Date & Time Formats
- π± Currencies
- π§ The sidebar (optional module rail)
- π§© Preference templates
- π Display order (modules, Watchtower cards) β Developer Guide
- Theming & Dark Mode
- ποΈ Recent β getting back to what you were doing
- β¨οΈ Command palette (βK)
- π Searching inside tickets
- π Attached documents
-
MobileβFriendly
- β³ π« Mobile: Tickets
- β³ π» Mobile: Assets
- β³ π Mobile: Calendar
- β³ π Mobile: Knowledge
- β³ π¦ Mobile: Service Status
- β³ πΌ Mobile: Watchtower
- β³ π§© Mobile: Problem Management
- β³ π Mobile: Change Management
- β³ πΏ Mobile: Software
- β³ β Mobile: Tasks
- β³ π Mobile: Forms
- β³ π Mobile: Contracts
- β³ π Mobile: Domains
- β³ π Mobile: People
- β³ π Mobile: Projects
- β³ ποΈ Mobile: Files
- β³ π Mobile: LMS
- β³ πΊοΈ Mobile: CMDB
- β³ πΊοΈ Mobile: Network Mapper
- β³ π§ Mobile: Process Mapper
- β³ βοΈ Mobile: Workflow
- β³ π₯οΈ Mobile: System
- β³ π Mobile: Reporting
- β³ π Mobile: System Wiki
- β³ π Mobile: Self-Service Portal
- β³ π§° Mobile: Techniques & Tricks
-
Security
- Layer 1 β which modules you can enter
- β³ π§© Module Access Control
- β³ π οΈ Module Access β Developer Guide
- β³ π Switching modules off
- β³ π οΈ Module availability β Developer Guide
- β³ π Module availability β design (#217)
- Layer 2 β what you can administer
- β³ π Roles & Permissions
- β³ π οΈ Roles β Developer Guide
- β³ π€ Why capabilities are constants
- Layer 3 β the System module
- β³ π Admin Access Control
- Hardening
- β³ π Security review response 2026-08
- β³ π‘οΈ Security hardening 2026-08
- β³ π οΈ Security hardening 2026-08 β Developer Guide
- β³ π‘οΈ Round three β plain English
- β³ π οΈ Round three β Developer Guide
- β³ π‘οΈ CSRF protection (S4) β Developer Guide
- Single Sign-On (SSO)
- ποΈ LDAP & Active Directory
- π CardDAV contact sync
- Browser Extension
- API Reference
-
π REST API β how it works
- β³ π Proposal: custom fields, inventory import and change evidence (#194)
- β³ π οΈ Custom fields, evidence + inventory - review (#195-#197)
- β³ π οΈ Long forms in a task's Work view - review (#198)
- β³ π« REST API: Tickets
- β³ π» REST API: Assets
- β³ π΄ REST API: Problems
- β³ π REST API: Changes
- β³ π REST API: Knowledge
- β³ β REST API: Tasks
- β³ ποΈ REST API: CMDB
- β³ π REST API: Contracts
- β³ ποΈ REST API: Calendar
- β³ πΏ REST API: Software
- β³ π REST API: Domains
- β³ π¦ REST API: Service Status
- β³ βοΈ REST API: Morning Checks
- β³ π REST API: Forms
- β³ βοΈ REST API: Workflow
- β³ π·οΈ REST API: Cost centres
- β³ π§βπΌ REST API: Analysts
- β³ πΊοΈ REST API: Network Mapper
- β³ π§ Using the API docs page
- β³ π OpenAPI specification
- β³ β OpenAPI: kept correct
- β³ π οΈ Maintaining the catalogue
- Watchtower
-
Tickets
- β³ π οΈ Inbox.js map β Developer Guide
- β³ π οΈ Floating windows & the file viewer β Developer Guide
- β³ π οΈ Tickets settings β Developer Guide
- β³ ποΈ The ticket workspace
- β³ π The ticket table
- β³ π Rota copy and paste β Developer Deep Dive
- β³ β Checklists & SOPs
- β³ βοΈ Mandatory fields
- β³ π§Ύ Custom ticket fields
- β³ π·οΈ Ticket categories
- β³ π₯ Assigning tickets to a team, and escalation
- β³ π’ One board across every company
- β³ Mailbox Authentication
- β³ π€ Email send log
- β³ π Attachment size limits and large emails
- β³ Basic IMAP mailboxes
- β³ Email rendering & images
- β³ SLA Management
- β³ WhatsApp channel
-
β³
βοΈ Telegram channel - β³ β CSAT company scope and filters β Developer Guide
- β³ π₯ Microsoft Teams channel
- β³ π¨οΈ Mattermost channel
- β³ π¬ Web chat channel
- β³ π£ Slack channel
- β³ π Linking tickets
- β³ β Record previews
- β³ π Ticket notes: internal or shared
- β³ ποΈ Canned responses
- β³ βοΈ Limiting replies to particular senders
- β³ π¨ Telling the analyst a ticket is theirs
- β³ βοΈ Email signatures
- β³ π The public web address
- β³ π’ Ticket numbering
- β³ π Raising a ticket for someone else
- β³ π Merging tickets
- β³ π Confidential tickets
- β³ π₯ Portal managers
- β³ π Who has seen a ticket
- β³ π Reading long tickets
- β³ β Splitting tickets
- β³ β Selecting several tickets
- β³ ποΈ The folder pane
- β³ π½ Just my tickets, or no closed ones
- β³ π οΈ Snoozing tickets β Developer Guide
- β³ π₯ Collision detection
- β³ β±οΈ Time tracking
- β³ π Case reports - a ticket and its work as one PDF
- β³ π Scheduled work in your own calendar
- Problem Management
- Tasks
- π Projects
-
Assets
- β³ π’ Moving an asset between companies
- β³ π Shared asset locations
- β³ π§βπΌ Assigning assets to analysts
- β³ π Warranty and lease alerts
- β³ π Leases
- β³ π Saved table views
- β³ π¨οΈ Recording anything, and importing it
- β³ π§© Asset type layouts
- β³ π Inventory freshness
- β³ π Linked configuration item
- β³ π Connected assets
- β³ π Asset review
- β³ π·οΈ QR asset labels
- β³ π Who holds what, and handover documents
- β³ π₯οΈ The inventory agent (PowerShell)
- β³ ποΈ Proxmox VE servers
- β³ βοΈ VMware Cloud Director servers
- β³ πͺ Hyper-V and Failover Clusters
- β³ π Linking equipment to tickets
- β³ βοΈ Follow-up tasks on a ticket
- Knowledge
- Change Management
- Calendar
- Morning Checks
- Reporting
- Software
-
Forms
- β³ π¨ The form designer β Developer Guide
- β³ π Layout & the grid β Developer Guide
- β³ ποΈ Collections β grouping submissions
- β³ π Submissions as PDFs
- β³ β‘ What happens next β a form's own actions
- β³ π οΈ Sections & conditional logic β Developer Guide
- β³ π οΈ Lookup fields β Developer Guide
- β³ π‘οΈ Catalogue request approvals
- People
- Domains
- ποΈ Files
- Contracts
- Service Status
- π Notifications
- π¨ War Room
- Self-Service Portal
- LMS
- Process Mapper
- CMDB
- Network Mapper
- Workflows
- Issue trackers (Jira, Azure DevOps)
- π‘ Zabbix (monitoring)
- π¬ Microsoft Teams alerts
- π 3CX (phone system)
- System
-
Overview
- β³ π Progress tracker
- β³ Concepts & vocabulary
- β³ Email routing & mailboxes
- β³ Settings: global vs per-company
- β³ Users & self-service
- β³ Staff cross-company access
- β³ π’ One board across every company
- β³ Worked examples
- β³ Pitfalls & gotchas
- β³ Scope: what it's for
- β³ π οΈ Developer Guide (make a module multi-company)
- β³ ποΈ Case study: CMDB (a linked graph)
- β³ π§ͺ Test harness (prove it's isolated)
- What this is
-
π Bugs resolved
- β³ π« #226 A picture on a note could not be closed
- β³ π» #222 The Assets page never loaded in 4.3.0
- β³ βοΈ #214 A "contains" condition did not match capitals
- β³ βοΈ #216 A workflow email from a chosen mailbox always failed
- β³ π³ The Docker image was missing PHP extensions
- β³ π A failed DNS lookup read as a missing record
- β³ π A link could change data
- β³ π Access outlived its removal
- β³ π Knowledge articles could run scripts
- β³ π Knowledge writes ignored permissions
- β³ π Company boundaries (Oct 2026)
- β³ π Smaller gaps (Oct 2026)
- β³ π Escaped text could leave its attribute
- β³ π Task descriptions were not cleaned
- β³ π Task documents ignored company scope
- β³ π Repeating tasks ignored company scope
- β³ π¬ #183 Mailbox checks overlapped
- β³ π #188 Transfer lock shown off when unknown
- β³ β #184 Subtask names and Overdue
- β³ π§© #186 Teams: the buttons did nothing
- β³ π Text in a change could run script
- β³ π AI settings changed without the AI permission
- β³ πͺ #178 Deleting an analyst failed
- β³ π« A team with no departments showed 0 tickets
- β³ π Projects: adding a phase did nothing on Save
- β³ π Leavers could still sign in
- β³ πΌοΈ Logo and courses broke on Apache with PHP-FPM
- β³ π’ Chat tickets ignored your ticket numbering
- β³ π Dates shown as a dash, or in server time
- β³ π Assets β Users showed people from other companies
- β³ π Restricted analysts could read other modules' data
- β³ πΌοΈ Replies with a picture in the thread failed to send
- β³ π Reply attachments never reached the customer
- β³ π οΈ Outbound email attachments β Developer Guide
- β³ π A global SSO provider was missing from the portal
- β³ π Behind a proxy, the SSO redirect said http
- β³ βοΈ The portal tagline moved when you saved it
- β³ π¨ The portal settings screen forgot what you saved
- β³ π‘οΈ The approvals inbox said "Error" and nothing else
- β³ π A table's answers were missing from the PDF
- β³ β A single-select column let you tick every option
- β³ π The portal ignored a form's field widths
- β³ π The tasks board stopped taking clicks
- β³ ποΈ #121 The index list is out of date after upgrading
- β³ π #133 The calendar subscription was empty
- β³ π #131 Tasks always reopened on the board
- β³ π₯ #129 Every page returned HTTP 500 after upgrading
- β³ π³ #127 A PHP warning above the System page
- β³ π #126 Notes stamped with the server's clock
- β³ π Storing every date in UTC
- β³ πͺ The portal was down for everyone signed in
- β³ βοΈ #120 Workflow notes could never be written
- β³ βοΈ #123 Three errors when running Database Verification
- β³ π #122 The description box was a stub in the corner
- β³ π£ Demo data deleted real accounts
- β³ π #117 Sign-in redirected to the wrong address
- β³ π¨ #108 The priority dot was invisible
- β³ β±οΈ #116 Time logged from the right-click menu
- β³ π #114 API keys refused by our own guard
- β³ ποΈ #110 Assigning a task told nobody
- β³ πͺ #107 Signed out while still working
- β³ π #103 "Share with Requester" reached nobody
- β³ π #102 Search found nothing for hyphens
- β³ πͺ #101 Source code editor opened behind
- β³ βοΈ #88 Subtasks could not be ticked off
- β³ π» #84 Asset deep link selected nothing
- β³ π« #79 A new ticket arrived with no status
- β³ π§ #79 A ticket from email did not say so
- β³ π #78 Bell opened to nothing
- β³ π¬ #77 Mail only collected from Inbox
- β³ π #74 The default password could not be changed
- β³ π¦ #70 Renaming an impact level
- β³ π€ #67 App-only mailboxes could not send
- β³ π #45 Verify only ever worked for Microsoft
- β³ π #45 IMAP reported as not authenticated
- β³ βοΈ An email template stopped escaping itself
- β³ π The portal dashboard showed the wrong time
- β³ π’ The folder said 99 and the list showed 96