Skip to content

[BNE-148] Create work package link block via hash command - #246

Merged
ihordubas99 merged 1 commit into
devfrom
feature/bne-148-create-work-package-link-block-via-hash-command
Sep 30, 2026
Merged

ihordubas99 merged 1 commit into
devfrom
feature/bne-148-create-work-package-link-block-via-hash-command

Conversation

@ihordubas99

@ihordubas99 ihordubas99 commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Ticket

https://community.openproject.org/wp/BNE-148

What are you trying to accomplish?

# to ### insert an inline work package link. This adds #### for a block-sized one, so creating a card stays the same gesture people already know instead of inserting a link and then resizing it. A run longer than #### stops being a command and stays on screen as typed.

Screenshots

demo.mp4

What approach did you choose and why?

The card is built by inserting the chip and promoting it right away, so the line splits through the very code path that already runs when an inline link is resized into a card - which is the behaviour the ticket asks for, without a second implementation of it. Both steps share one transaction, so the intermediate chip never surfaces as an undo step.

The ##### case needs BlockNote's shouldOpen rather than us closing the menu: BlockNote restarts the menu on every # but only calls getItems when the query text changes, and the fifth hash leaves it empty - so we are never asked, and the menu would hang open swallowing Enter.

Wiring the menu moved behind <OpenProjectHashMenu />, next to
<OpenProjectFormattingToolbar />: consumers no longer repeat the trigger character, and anything we need internally later costs them nothing. OpenProject side: opf/openproject#25231 - merge it after this is released, it needs the new export.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The canOpenHashMenu gating logic (and its unit test) appears to disable the menu at exactly 4 hashes, which can break the intended #### block-card trigger flow.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adds support for inserting an OpenProject work package block card via a #### hash trigger, refactors the hash menu wiring into a reusable OpenProjectHashMenu component, and introduces new trigger/insert logic with expanded unit + browser test coverage.

Changes:

  • Implemented hash-trigger targeting (#/##/### => inline chip sizes, #### => block card; longer runs remain literal) and updated hash menu behavior accordingly.
  • Introduced <OpenProjectHashMenu /> to encapsulate # menu wiring and updated the demo app + test editor harness to use it.
  • Refactored/expanded tests (including new browser integration coverage) and added shared headless editor helpers for jsdom tests.
File summaries
File Description
test/lib/utils/inlineChipActions.test.ts Refactors tests to use shared headless editor helpers and node-type constants.
test/lib/components/integration/editor.undo.browser.test.tsx Adds undo coverage for block cards inserted via #### hash trigger.
test/lib/components/integration/blockWorkPackageHashTrigger.browser.test.tsx New browser integration coverage for #### block-card trigger behavior and edge cases.
test/lib/components/HashMenu/hashTrigger.test.ts New unit tests for hash targeting and menu-open gating behavior.
test/lib/components/HashMenu/editorUtils.test.ts New unit tests for inserting chips/cards and cleaning up trigger hashes.
test/lib/components/hashMenu.test.ts Removes legacy hash menu tests replaced by more focused new suites.
test/helpers/renderEditor.tsx Switches test editor harness to use <OpenProjectHashMenu />.
test/helpers/headlessEditor.ts Adds shared headless BlockNote editor utilities for jsdom-level unit tests.
test/helpers/editorHelpers.ts Adds helpers for inserting block cards via hash in browser tests; refactors hash insertion utilities.
src/App.tsx Updates demo app to use <OpenProjectHashMenu /> instead of manual wiring.
lib/utils/suggestionMenu.ts Adds utility to programmatically close the suggestion menu.
lib/utils/inlineChipActions.ts Adjusts inline chip lookups/resolution to use editor.transact for doc access.
lib/index.ts Exports OpenProjectHashMenu from the public library entrypoint.
lib/components/HashMenu/useHashWpMenu.ts Adds hash target resolution + closes menu for unsupported hash runs; inserts block card for ####.
lib/components/HashMenu/OpenProjectHashMenu.tsx New component encapsulating hash menu controller wiring.
lib/components/HashMenu/index.ts Re-exports OpenProjectHashMenu.
lib/components/HashMenu/HashWpMenu.tsx Adds data-testid="hash-menu" to support browser tests.
lib/components/HashMenu/hashTrigger.ts New trigger parsing and shouldOpen gating logic.
lib/components/HashMenu/editorUtils.ts Updates insertion logic to support inserting either an inline chip or a block card based on trigger target.
Review details
  • Files reviewed: 19/19 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/components/HashMenu/hashTrigger.ts
Comment thread test/lib/components/HashMenu/hashTrigger.test.ts Outdated
@ihordubas99
ihordubas99 force-pushed the feature/bne-148-create-work-package-link-block-via-hash-command branch from 87a4d1e to 06a5b02 Compare September 10, 2026 09:52
@ihordubas99
ihordubas99 force-pushed the feature/bne-148-create-work-package-link-block-via-hash-command branch from 06a5b02 to 2eb7ece Compare September 10, 2026 10:03
@ihordubas99
ihordubas99 marked this pull request as ready for review September 10, 2026 10:03

@judithroth judithroth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry it took so long until I could review this 😅
Nice work!

await expect.element(page.getByTestId('op-bn-work-package--type')).not.toBeInTheDocument();
});

it('undoes block card inserted via #### hash — card is gone', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ihordubas99
ihordubas99 merged commit fadc23c into dev Sep 30, 2026
6 checks passed
@ihordubas99
ihordubas99 deleted the feature/bne-148-create-work-package-link-block-via-hash-command branch September 30, 2026 14:07
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants