Skip to content

refactor: Encounter shortcut#16108

Open
abhimanyurajeesh wants to merge 4 commits intodevelopfrom
manyu/fix/#14285
Open

refactor: Encounter shortcut#16108
abhimanyurajeesh wants to merge 4 commits intodevelopfrom
manyu/fix/#14285

Conversation

@abhimanyurajeesh
Copy link
Contributor

@abhimanyurajeesh abhimanyurajeesh commented Mar 13, 2026

fixes #14285

image

Tagging: @ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate the bug or test the new feature.
  • Update product documentation.
  • Ensure that UI text is placed in I18n files.
  • Prepare a screenshot or demo video for the changelog entry and attach it to the issue.
  • Request peer reviews.
  • Complete QA on mobile devices.
  • Complete QA on desktop devices.
  • Add or update Playwright tests for related changes

Summary by CodeRabbit

  • New Features

    • Added new encounter shortcuts: r (service request), m (medication request), f (questionnaire), shift+c (mark-as-completed), shift+d (dispense).
    • Recently-used actions are shown and persisted for faster access.
  • Improvements

    • Many encounter shortcuts are now always available (broader availability).
    • Shortcut badges updated and displayed across encounter UI for clearer affordance.
    • Removed legacy per-action shortcut UI (streamlined command handling).
  • Behavior Changes

    • Some questionnaire shortcuts (q1–q9) and certain overview shortcut keys were removed.

@abhimanyurajeesh abhimanyurajeesh requested review from a team and Copilot March 13, 2026 13:57
@abhimanyurajeesh abhimanyurajeesh requested a review from a team March 13, 2026 13:57
@netlify
Copy link

netlify bot commented Mar 13, 2026

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit c4a7117
🔍 Latest deploy log https://app.netlify.com/projects/care-ohc/deploys/69b417da5096740008143eed
😎 Deploy Preview https://deploy-preview-16108.preview.ohc.network
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

Walkthrough

Replaces legacy encounter-specific shortcut hooks with a centralized ShortcutContext-based system, removes old utility APIs, updates keyboardShortcuts.json to make many encounter shortcuts always-active, and updates encounter UI components to use ShortcutBadge and the new shortcut subcontext.

Changes

Cohort / File(s) Summary
Shortcut utilities
src/Utils/keyboardShortcutUtils.ts
Removed legacy public APIs (useShortcutDisplays, ShortcutContext types, shortcutActionHandlers); retained formatKeyboardShortcut and simplified shortcutActionHandler to always call element.click().
Removed encounter hooks
src/hooks/useEncounterShortcuts.ts
Deleted entire file: removed useEncounterShortcuts, useEncounterShortcutDescriptions, and useEncounterShortcutDisplays along with associated display/description logic.
Shortcut config
src/config/keyboardShortcuts.json
Changed many encounter shortcuts from permission-gated to when: "always"; removed several g overview and q1–q9 questionnaire entries; added/changed keys (e.g., r, m, f, shift+u, shift+c, shift+d).
Encounter command dialog
src/components/Encounter/EncounterCommandDialog.tsx
Switched to useShortcutDisplay from ShortcutContext; updated to use extended useEncounter() (adds actions, selectedEncounterId, primaryEncounterId), centralized handleAction, URL builder, navigation via useNavigate, and recent-action persistence.
Pages — Encounter UI updates
src/pages/Encounters/EncounterShow.tsx, src/pages/Encounters/tabs/overview/quick-actions.tsx, src/pages/Encounters/tabs/overview/clinical-history-overview.tsx, src/pages/Encounters/tabs/overview/FormsDialog.tsx, src/pages/Encounters/.../summary-panel-*.tsx, src/pages/Encounters/MarkEncounterAsCompletedDialog.tsx
Replaced legacy CommandShortcut/KeyboardShortcutBadge/getShortcutDisplay usages with ShortcutBadge and useShortcutSubContext("encounter"); removed open-dialog custom events and per-component shortcut hooks; updated QuickAction/QuickActionContent props to use actionId instead of shortcut.

Possibly related PRs

Suggested labels

needs review, needs testing

Suggested reviewers

  • rithviknishad
  • nihal467
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'refactor: Encounter shortcut' is directly related to the main objective of refactoring the Encounter shortcut system to use the new shortcut framework as specified in issue #14285.
Description check ✅ Passed The PR description includes the linked issue reference (#14285), a screenshot demonstrating the changes, and the merge checklist following the template structure, though some sections remain unchecked.
Linked Issues check ✅ Passed The PR successfully refactors the Encounter shortcut system to use the new shortcuts framework by removing old hook implementations, updating components to use ShortcutBadge and centralized useShortcutDisplay, and extending keyboard shortcuts configuration with new actions.
Out of Scope Changes check ✅ Passed All changes are directly related to the Encounter shortcut refactoring objective; modifications to keyboard shortcuts configuration, component updates, and hook consolidation are all in-scope to the PR's stated goal.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch manyu/fix/#14285
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@abhimanyurajeesh abhimanyurajeesh marked this pull request as draft March 13, 2026 13:58
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 13, 2026

Deploying care-preview with  Cloudflare Pages  Cloudflare Pages

Latest commit: a9da69a
Status: ✅  Deploy successful!
Preview URL: https://eb9f6177.care-preview-a7w.pages.dev
Branch Preview URL: https://manyu-fix--14285.care-preview-a7w.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/Encounter/EncounterCommandDialog.tsx`:
- Around line 432-434: The dependency array in EncounterCommandDialog uses
inconsistent optional chaining for the required prop; replace the optional chain
usage of encounter?.status with the direct property access encounter.status to
match the prop contract. Update the dependency list where
encounter.encounter_class and encounter?.status are referenced so it reads
encounter.encounter_class and encounter.status, ensuring consistency with the
EncounterCommandDialog prop definition and avoiding unnecessary optional checks.

In `@src/config/keyboardShortcuts.json`:
- Around line 133-155: The handleAction function currently executes
shortcut-triggered actions without checking permissions; add early-return guards
in handleAction that verify canWriteSelectedEncounter (or the appropriate
permission flag) before performing any write/navigation/dialog
actions—specifically gate actions with action names add-allergy, add-diagnosis,
add-symptoms, add-service-request, add-medication-request, update-encounter and
dialog actions mark-as-completed, dispense, restart-encounter, assign-location,
manage-care-team, manage-departments; if the permission check fails, return
early (no-op) and optionally surface a user-visible permission error.

In `@src/pages/Encounters/tabs/overview/FormsDialog.tsx`:
- Around line 139-145: The trigger wrapper is a plain <div> with only onClick
which breaks keyboard accessibility; update the element in FormsDialog (the
wrapper that uses setOpen and renders {trigger}) to be keyboard-accessible by
adding role="button", tabIndex={0}, and an onKeyDown handler that listens for
Enter and Space and calls setOpen(true) (mirroring the onClick), ensuring you
preventDefault where appropriate and keep the existing onClick behavior; this
will provide proper keyboard activation and role semantics for screen readers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: fe557f21-519e-4244-a059-01591b6745d4

📥 Commits

Reviewing files that changed from the base of the PR and between c6cd9a3 and c4a7117.

📒 Files selected for processing (8)
  • src/Utils/keyboardShortcutUtils.ts
  • src/components/Encounter/EncounterCommandDialog.tsx
  • src/config/keyboardShortcuts.json
  • src/hooks/useEncounterShortcuts.ts
  • src/pages/Encounters/EncounterShow.tsx
  • src/pages/Encounters/tabs/overview/FormsDialog.tsx
  • src/pages/Encounters/tabs/overview/clinical-history-overview.tsx
  • src/pages/Encounters/tabs/overview/quick-actions.tsx
💤 Files with no reviewable changes (1)
  • src/hooks/useEncounterShortcuts.ts

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors Encounter-related keyboard shortcuts to use the new shortcut framework (ShortcutContext + data-shortcut-id click targets) instead of the legacy useEncounterShortcuts hook, and updates encounter UI surfaces to render the new shortcut badges.

Changes:

  • Replaces legacy encounter shortcut hooks/badges with ShortcutBadge + useShortcutSubContext("encounter").
  • Removes useEncounterShortcuts.ts and associated utilities, shifting shortcut execution to DOM click targets.
  • Updates keyboardShortcuts.json encounter bindings and enables index-based tab shortcuts in NavTabs.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/pages/Encounters/tabs/overview/quick-actions.tsx Migrates Quick Actions shortcut display from old display hook to ShortcutBadge/actionId.
src/pages/Encounters/tabs/overview/clinical-history-overview.tsx Adds ShortcutBadge hint for Clinical History link.
src/pages/Encounters/tabs/overview/FormsDialog.tsx Makes Forms dialog trigger discoverable via data-shortcut-id.
src/pages/Encounters/EncounterShow.tsx Sets shortcut sub-context to encounter, updates Encounter Actions shortcut UI, enables index tab shortcuts.
src/hooks/useEncounterShortcuts.ts Deletes legacy encounter shortcut hook implementation.
src/config/keyboardShortcuts.json Adjusts encounter shortcut bindings/conditions and removes some legacy “go to …” bindings.
src/components/Encounter/EncounterCommandDialog.tsx Switches shortcut display source to useShortcutDisplay and inlines action execution logic.
src/Utils/keyboardShortcutUtils.ts Removes deprecated useShortcutDisplays and simplifies shortcut action click handling.

@github-actions
Copy link

github-actions bot commented Mar 13, 2026

🎭 Playwright Test Results

Status: ✅ Passed
Test Shards: 3

Metric Count
Total Tests 271
✅ Passed 271
❌ Failed 0
⏭️ Skipped 0

📊 Detailed results are available in the playwright-final-report artifact.

Run: #7445

Copilot AI review requested due to automatic review settings March 16, 2026 04:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors encounter-related keyboard shortcuts to use the newer ShortcutContext/data-shortcut-id click-based shortcut system, and updates encounter UI to display shortcut badges in key places.

Changes:

  • Replaces the legacy encounter shortcut hook usage with useShortcutSubContext("encounter") and ShortcutBadge rendering.
  • Updates keyboardShortcuts.json encounter shortcuts (new keys and “always” conditions) and removes several old “go to …” combos.
  • Removes legacy helper hooks (useEncounterShortcuts, useShortcutDisplays) and simplifies shortcut click handling.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/pages/Encounters/tabs/overview/quick-actions.tsx Switches quick actions to use actionId + ShortcutBadge instead of legacy display hook.
src/pages/Encounters/tabs/overview/clinical-history-overview.tsx Adds a shortcut badge to the clinical history CTA.
src/pages/Encounters/tabs/overview/FormsDialog.tsx Wires “add-questionnaire” via data-shortcut-id instead of custom DOM events.
src/pages/Encounters/EncounterShow.tsx Sets shortcut sub-context to encounter, uses ShortcutBadge, enables tab index shortcuts.
src/hooks/useEncounterShortcuts.ts Removes old encounter shortcut implementation.
src/config/keyboardShortcuts.json Updates encounter shortcut definitions (keys + conditions), removes some older entries.
src/components/Scan/GenericQRScanDialog.tsx Adjusts scanning reset behavior when dialog closes.
src/components/Patient/PatientInfoHoverCard.tsx Adds a “Deceased” badge to the hover card header when applicable.
src/components/Encounter/EncounterCommandDialog.tsx Migrates to useShortcutDisplay and inlines encounter action handling logic.
src/Utils/keyboardShortcutUtils.ts Removes deprecated display hook and simplifies shortcut click handler to element.click().
CLAUDE.md Expands repository guidance/documentation for Claude Code.

@abhimanyurajeesh abhimanyurajeesh marked this pull request as ready for review March 16, 2026 06:50
Copilot AI review requested due to automatic review settings March 16, 2026 06:50
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/components/Encounter/EncounterCommandDialog.tsx (2)

102-109: ⚠️ Potential issue | 🟡 Minor

Wrap JSON.parse in try-catch to handle corrupted localStorage.

If localStorage contains invalid JSON (from corruption, browser extensions, or manual tampering), JSON.parse will throw a SyntaxError and crash the component.

🛡️ Proposed defensive fix
 const getRecentActions = useCallback((): string[] => {
   const stored = localStorage.getItem(STORAGE_KEY);
   if (stored) {
-    const parsed = JSON.parse(stored);
-    return Array.isArray(parsed) ? parsed.slice(0, MAX_RECENT_ACTIONS) : [];
+    try {
+      const parsed = JSON.parse(stored);
+      return Array.isArray(parsed) ? parsed.slice(0, MAX_RECENT_ACTIONS) : [];
+    } catch {
+      localStorage.removeItem(STORAGE_KEY);
+      return [];
+    }
   }
   return [];
 }, []);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/Encounter/EncounterCommandDialog.tsx` around lines 102 - 109,
getRecentActions currently calls JSON.parse on localStorage.getItem(STORAGE_KEY)
without error handling; wrap the JSON.parse call in a try/catch inside
getRecentActions so any SyntaxError or other parse error returns an empty array
(or a safe fallback) and avoids crashing the component, still respecting
MAX_RECENT_ACTIONS when parsed value is an array.

288-291: 🧹 Nitpick | 🔵 Trivial

Inconsistent optional chaining on required encounter prop.

Line 288 uses encounter.encounter_class (direct access) while line 289 uses encounter?.status (optional chaining). Since encounter is a required prop, the optional chaining is unnecessary and inconsistent.

🔧 Proposed fix
         {
           id: "mark-as-completed",
           label:
             encounter.encounter_class === "imp" &&
-            encounter?.status !== "discharged"
+            encounter.status !== "discharged"
               ? t("mark_for_discharge")
               : t("mark_as_completed"),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/Encounter/EncounterCommandDialog.tsx` around lines 288 - 291,
The code inconsistently uses optional chaining on the required prop `encounter`;
update the conditional in EncounterCommandDialog so both properties are accessed
consistently (e.g., replace `encounter?.status` with `encounter.status`) and
ensure the prop type for `encounter` remains required so no runtime null checks
are needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/config/keyboardShortcuts.json`:
- Around line 133-143: Add Playwright regression tests that cover the new
always-on encounter shortcuts defined in keyboardShortcuts.json: create specs
that (1) verify the shortcut triggers the expected behavior when the target
element with the corresponding data-shortcut-id (e.g., "add-allergy",
"add-service-request", "add-medication-request", "add-questionnaire",
"update-encounter", "clinical-history", "open-command-dialog",
"mark-as-completed", "dispense") is present in the DOM, and (2) verify the
shortcut is a no-op when that data-shortcut-id element is not rendered due to
permissions/state gating; ensure tests simulate the relevant keyboard combos
(including modifier combos like "shift+u", "cmd+e"/"ctrl+e") and assert side
effects or lack thereof, relying on DOM presence checks rather than internal
permission calls.

In `@src/pages/Encounters/tabs/overview/summary-panel-actions.tab.tsx`:
- Around line 60-65: Extract the inline object shape into a named interface
(e.g., SummaryPanelAction) with fields label: string, onClick: () => void,
hideOnMobile: boolean, and optional shortcut?: React.ReactNode; then replace the
inline "satisfies { ... }[]" with "satisfies SummaryPanelAction[]" (and add the
new interface declaration near the top of the module or next to related types).
Update any references to the anonymous shape to use SummaryPanelAction to
improve reuse and clarity (ensure the interface name matches the one used in the
satisfies expression).

---

Outside diff comments:
In `@src/components/Encounter/EncounterCommandDialog.tsx`:
- Around line 102-109: getRecentActions currently calls JSON.parse on
localStorage.getItem(STORAGE_KEY) without error handling; wrap the JSON.parse
call in a try/catch inside getRecentActions so any SyntaxError or other parse
error returns an empty array (or a safe fallback) and avoids crashing the
component, still respecting MAX_RECENT_ACTIONS when parsed value is an array.
- Around line 288-291: The code inconsistently uses optional chaining on the
required prop `encounter`; update the conditional in EncounterCommandDialog so
both properties are accessed consistently (e.g., replace `encounter?.status`
with `encounter.status`) and ensure the prop type for `encounter` remains
required so no runtime null checks are needed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 776ae918-9890-4ddc-886e-a12fde1ff2aa

📥 Commits

Reviewing files that changed from the base of the PR and between c4a7117 and a9da69a.

📒 Files selected for processing (7)
  • src/components/Encounter/EncounterCommandDialog.tsx
  • src/config/keyboardShortcuts.json
  • src/pages/Encounters/MarkEncounterAsCompletedDialog.tsx
  • src/pages/Encounters/tabs/overview/FormsDialog.tsx
  • src/pages/Encounters/tabs/overview/summary-panel-actions.tab.tsx
  • src/pages/Encounters/tabs/overview/summary-panel-details-tab/encounter-details.tsx
  • src/pages/Encounters/tabs/overview/summary-panel-details-tab/summary-panel-encounter-details.tsx
💤 Files with no reviewable changes (1)
  • src/pages/Encounters/tabs/overview/FormsDialog.tsx

@greptile-apps
Copy link

greptile-apps bot commented Mar 16, 2026

Greptile Summary

This PR refactors the encounter keyboard shortcut system, replacing the dedicated useEncounterShortcuts hook and custom DOM events with a unified ShortcutContext / ShortcutBadge approach — the shortcut badge component now serves as both the visible shortcut indicator and the DOM click-target for shortcutActionHandler. The changes reduce duplication across the codebase, simplify the shortcut configuration, and add new shortcuts (r for service request, m for medication request, shift+c for mark-as-completed).

Key points to note:

  • Hidden button pattern in encounter-details.tsx: mark-as-completed and dispense shortcuts are wired through hidden <Button className="hidden"> elements containing a ShortcutBadge. The mechanism relies on click-event bubbling from the badge <div> through a display:none parent — functional in all browsers, but non-obvious. Adding a brief comment would aid maintainability.
  • Duplicate data-shortcut-id="dispense": Both summary-panel-actions.tab.tsx (visible badge inside the Dispense button) and encounter-details.tsx (hidden button) render a badge with actionId="dispense". document.querySelector returns the first DOM match, creating an implicit dependency on render order. One of the two could be removed.
  • buildEncounterUrl is now inlined in EncounterCommandDialog rather than shared — a candidate for extraction if other components need the same logic.
  • "when": "always" in keyboardShortcuts.json is used for write-gated shortcuts; at runtime the permission check happens implicitly via DOM-element presence, but the annotation is misleading documentation.
  • Removal of navigation shortcuts (g *) and questionnaire shortcuts (q 1–9) means the "Go to" command-dialog entries no longer display shortcut hints — this appears intentional per the simplified design.

Confidence Score: 4/5

  • Safe to merge with minor follow-up on the hidden-button pattern and duplicate shortcut-target cleanup.
  • No runtime-breaking logic issues found. All new shortcuts have valid DOM targets. The main concerns are code clarity (hidden buttons, duplicate data-shortcut-id, misleading when annotations) rather than correctness. The refactor correctly gates write actions behind canWriteSelectedEncounter and the shortcut wiring works via standard event bubbling.
  • Pay close attention to encounter-details.tsx (hidden button pattern + duplicate dispense target) and keyboardShortcuts.json (misleading "when": "always" annotations for write-gated shortcuts).

Important Files Changed

Filename Overview
src/components/Encounter/EncounterCommandDialog.tsx Replaced useEncounterShortcuts + custom DOM event with self-contained handleAction and buildEncounterUrl. buildEncounterUrl is now duplicated here rather than shared. Removed add-questionnaire action from dialog; isLoading correctly removed from useMemo deps; added missing encounter.encounter_class / encounter.status deps.
src/config/keyboardShortcuts.json Many shortcuts removed (navigation g * combos, q 1–9, l, s, d, m c); new shortcuts added (r, m, shift+c). All write-gated actions now marked "when": "always" which is inaccurate documentation, since functionality is still gated by DOM element presence.
src/pages/Encounters/EncounterShow.tsx Replaced useEncounterShortcuts() + useEncounterShortcutDisplays() with useShortcutSubContext("encounter"); swapped CommandShortcut for ShortcutBadge; added enableIndexShortcut to NavTabs; removed tabTriggerClassName="max-w-36" constraint which could affect tab display with long labels.
src/pages/Encounters/tabs/overview/summary-panel-details-tab/encounter-details.tsx Added hidden buttons as DOM shortcut targets for mark-as-completed and dispense. Pattern relies on click-event bubbling from ShortcutBadge div inside display:none button. Creates duplicate data-shortcut-id="dispense" alongside SummaryPanelActionsTab.
src/pages/Encounters/tabs/overview/summary-panel-actions.tab.tsx Added ShortcutBadge for the dispense action only; other actions lack shortcut badges. The dispense badge is also present in encounter-details.tsx, creating two DOM elements with the same data-shortcut-id.

Comments Outside Diff (1)

  1. src/config/keyboardShortcuts.json, line 288-294 (link)

    "when": "always" is misleading for write-gated actions

    Several shortcuts that require write permission (add-allergy, add-service-request, add-medication-request, update-encounter, mark-as-completed, dispense) are now annotated with "when": "always". In practice, these shortcuts are no-ops for read-only users because the DOM elements with the corresponding data-shortcut-id only render when canWriteSelectedEncounter is true — but the when field as documented does not reflect that.

    The ShortcutContext does not evaluate the when field at runtime, so the annotation is purely for human documentation. Keeping the original "when": "canEdit" (or similar) for write-gated shortcuts would make the JSON self-documenting and accurate.

Last reviewed commit: a9da69a

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors Encounter-page keyboard shortcuts to use the new ShortcutContext + ShortcutBadge mechanism (DOM data-shortcut-id click handlers) instead of the legacy useEncounterShortcuts hook, aiming for consistent shortcut badges across encounter actions.

Changes:

  • Removes the legacy encounter shortcut hook (useEncounterShortcuts) and wires Encounter pages into the new shortcut sub-context (useShortcutSubContext("encounter")).
  • Adds ShortcutBadge instances across encounter overview UI (update encounter, clinical history, quick actions) and summary panel actions.
  • Updates keyboardShortcuts.json for the encounter context with new key mappings and removes older multi-key/prefix mappings.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/pages/Encounters/EncounterShow.tsx Switches Encounter to useShortcutSubContext("encounter"), updates command dialog trigger to use ShortcutBadge, enables tab index shortcuts.
src/components/Encounter/EncounterCommandDialog.tsx Replaces legacy encounter shortcut hooks with useShortcutDisplay and local action execution helpers.
src/config/keyboardShortcuts.json Updates encounter shortcut definitions (new keys + “always” conditions) and removes older ones.
src/pages/Encounters/tabs/overview/quick-actions.tsx Migrates quick actions to ShortcutBadge/actionId instead of legacy display hook.
src/pages/Encounters/tabs/overview/summary-panel-actions.tab.tsx Adds shortcut badge rendering for dispense in the actions list.
src/pages/Encounters/tabs/overview/clinical-history-overview.tsx Adds shortcut badge to the “See clinical history” link.
src/pages/Encounters/tabs/overview/summary-panel-details-tab/* Adds shortcut badge to the “Update encounter” action and hidden triggers for some actions.
src/pages/Encounters/tabs/overview/FormsDialog.tsx Removes the legacy custom-event listener used by old shortcut plumbing.
src/pages/Encounters/MarkEncounterAsCompletedDialog.tsx Adds a shortcut badge to the confirm action button.
src/Utils/keyboardShortcutUtils.ts Removes deprecated shortcut display utilities and simplifies action handling to element.click().

@parvathyns-creator
Copy link

@nihal467 this looks fine

@abhimanyurajeesh
Copy link
Contributor Author

@nihal467 this looks fine

@parvathyns-creator can you please test all the shortcuts, across CARE ?

@github-actions github-actions bot added needs-triage question Further information is requested labels Mar 16, 2026
@abhimanyurajeesh abhimanyurajeesh removed question Further information is requested needs-triage labels Mar 16, 2026
@parvathyns-creator
Copy link

parvathyns-creator commented Mar 16, 2026

@nihal467 this looks fine

@parvathyns-creator can you please test all the shortcuts, across CARE ?

@abhimanyurajeesh -The ESC (cancel) works only after entering values. If no values are entered, the shortcut isn't working. This can be seen in inventory transfers

@abhimanyurajeesh
Copy link
Contributor Author

@nihal467 this looks fine

@parvathyns-creator can you please test all the shortcuts, across CARE ?

@abhimanyurajeesh -The ESC (cancel) works only after entering values. If no values are entered, the shortcut isn't working. This can be seen in inventory transfers

@parvathyns-creator if the focus is in an input field the shortcut wont work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor Encounter shortcut to use new shortcut system

3 participants