Skip to content

fix: enhance category selection for ios devices - #16603

Open
navaspavil wants to merge 11 commits into
developfrom
fix-category-selection-ios
Open

fix: enhance category selection for ios devices#16603
navaspavil wants to merge 11 commits into
developfrom
fix-category-selection-ios

Conversation

@navaspavil

@navaspavil navaspavil commented Jul 27, 2026

Copy link
Copy Markdown
Member

This pull request updates the ResourceDefinitionCategoryPicker component to improve compatibility with iOS devices by adjusting focus behaviour.

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

Summary

  • Bug Fixes
    • Improved mobile iOS behavior in the category picker by disabling the drawer’s input/content repositioning, preventing the drawer’s search area from being unexpectedly moved during use.

@navaspavil
navaspavil requested review from a team and Copilot July 27, 2026 13:06
@github-actions

Copy link
Copy Markdown

⚠️ Merge Checklist Incomplete

Thank you for your contribution! To help us review your PR efficiently, please complete the merge checklist in your PR description.

Your PR will be reviewed once you have marked the appropriate checklist items.

To update the checklist:

  • Change - [ ] to - [x] for completed items
  • Only check items that are relevant to your PR
  • Leave items unchecked if they don't apply

The checklist helps ensure code quality, testing coverage, and documentation are properly addressed.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5ed6f368-4743-4afc-9193-9b62de847de7

📥 Commits

Reviewing files that changed from the base of the PR and between 4a47370 and 0202f81.

📒 Files selected for processing (1)
  • src/components/Common/ResourceDefinitionCategoryPicker.tsx

Walkthrough

The mobile resource definition category picker configures its Drawer with repositionInputs={false}.

Changes

Mobile Picker Handling

Layer / File(s) Summary
Drawer repositioning behavior
src/components/Common/ResourceDefinitionCategoryPicker.tsx
The mobile drawer disables input and content repositioning by setting repositionInputs to false.

Suggested reviewers: amjithtitus09, jacobjeevan

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly reflects the main change: improving iOS category selection behavior.
Description check ✅ Passed The description covers the change and includes the merge checklist with QA completion.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-category-selection-ios

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown

Greptile Summary

Updates the category picker’s focus behavior for iOS devices.

  • Disables automatic search-input focus when iOS is detected.
  • Applies the same device-specific focus setting to the drawer’s search tab content.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/components/Common/ResourceDefinitionCategoryPicker.tsx Adds iOS-aware autofocus behavior to the category picker’s search input and drawer search tab without introducing an eligible follow-up issue.

Reviews (7): Last reviewed commit: "fix: add autoFocus prop to TabsContent f..." | Re-trigger Greptile

Copilot AI 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.

Pull request overview

Improves touch/pen interaction handling in ResourceDefinitionCategoryPicker to make category/definition selection more reliable on iOS/touch devices.

Changes:

  • Added onPointerUp handlers to category, subcategory, and definition CommandItems to manually trigger selection for non-mouse pointer types.
  • Added a guard to ignore taps on the favorite toggle button inside definition items.
Comments suppressed due to low confidence (2)

src/components/Common/ResourceDefinitionCategoryPicker.tsx:623

  • Same issue as above: this onPointerUp handler can lead to duplicate handleCategorySelect(...) execution on touch/pen if onSelect also fires via a compatibility click. Please ensure the select logic is invoked only once per interaction (e.g., via a useRef guard shared between pointer + onSelect handlers).
            onPointerUp={(e) => {
              if (e.pointerType !== "mouse") {
                e.preventDefault();
                handleCategorySelect(category.slug, category.title);
              }

src/components/Common/ResourceDefinitionCategoryPicker.tsx:661

  • handleDefinitionSelect is non-idempotent (mutates recent list + toggles selection). With both onPointerUp and onSelect present, touch/pen interactions can potentially trigger selection twice if a compatibility click still fires. Please add a single-invocation guard between pointer and onSelect paths to ensure handleDefinitionSelect runs exactly once per user action.
        onPointerUp={(e) => {
          if (e.pointerType !== "mouse") {
            // Ignore taps on the favorite toggle button
            if ((e.target as HTMLElement).closest("button")) return;
            e.preventDefault();
            handleDefinitionSelect(definition);
          }

Comment thread src/components/Common/ResourceDefinitionCategoryPicker.tsx Outdated
Comment thread src/components/Common/ResourceDefinitionCategoryPicker.tsx Outdated

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/Common/ResourceDefinitionCategoryPicker.tsx`:
- Around line 586-591: Prevent duplicate selection handling in the CommandItem
onPointerUp handlers at
src/components/Common/ResourceDefinitionCategoryPicker.tsx:586-591, 619-624, and
655-663 by removing their selection calls or gating them so pointer activation
does not also trigger the existing onSelect callbacks; ensure definition
selection cannot toggle the same multiple-selection value twice or mutate the
history list unexpectedly.
🪄 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 Plus

Run ID: 152b54b4-5b77-42f0-9555-00461228762e

📥 Commits

Reviewing files that changed from the base of the PR and between bcb288a and 485431c.

📒 Files selected for processing (1)
  • src/components/Common/ResourceDefinitionCategoryPicker.tsx

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

🎭 Playwright Test Results

Status: ✅ Passed
Test Shards: 3

Metric Count
Total Tests 334
✅ Passed 333
❌ Failed 0
⏭️ Skipped 1

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

Run: #10482

Copilot AI review requested due to automatic review settings July 28, 2026 08:08
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 28, 2026

Copy link
Copy Markdown

Deploying care-preview with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0202f81
Status: ✅  Deploy successful!
Preview URL: https://7263fa9f.care-preview-a7w.pages.dev
Branch Preview URL: https://fix-category-selection-ios.care-preview-a7w.pages.dev

View logs

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

src/components/Common/ResourceDefinitionCategoryPicker.tsx:170

  • pointerSelectedRef can remain true when onPointerUp triggers a state change that re-renders/unmounts the CommandItem before the subsequent onSelect fires. In that case the next onSelect (e.g. keyboard/mouse, or after reopening) will be ignored once, causing a missed selection. Reset the ref on relevant state changes (like open/currentParent) so it can’t get stuck.

This issue also appears on line 673 of the same file.

  // Set on touch/pen pointerup to avoid double selection from the following onSelect.
  const pointerSelectedRef = useRef(false);

  // Sync open state with defaultOpen prop for controlled auto-open behavior
  useEffect(() => {
    if (defaultOpen) {
      setOpen(true);
    }
  }, [defaultOpen]);

src/components/Common/ResourceDefinitionCategoryPicker.tsx:680

  • This change is specifically addressing touch/stylus interaction quirks, but there doesn’t appear to be a Playwright spec covering touch selection or tapping the favorite (star) control without selecting the definition. Adding a regression test using locator.tap() / page.touchscreen.tap() would help prevent reintroducing double-selection and the favorite-tap mis-selection bug.
        onPointerUp={(e) => {
          if (e.pointerType !== "mouse") {
            // Ignore taps on the favorite toggle button
            if (e.target instanceof Element && e.target.closest("button"))
              return;
            pointerSelectedRef.current = true;
            handleDefinitionSelect(definition);
          }

Copilot AI review requested due to automatic review settings July 28, 2026 09:05

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (3)

src/components/Common/ResourceDefinitionCategoryPicker.tsx:635

  • Same issue as above: pointerSelectedRef can remain true if handleCategorySelect re-renders/unmounts the item before cmdk triggers onSelect, which can cause a subsequent keyboard/mouse selection to be dropped. Reset the ref after a tick in the onPointerUp path as a fallback.
            onPointerUp={(e) => {
              if (e.pointerType !== "mouse") {
                pointerSelectedRef.current = true;
                handleCategorySelect(category.slug, category.title);
              }

src/components/Common/ResourceDefinitionCategoryPicker.tsx:680

  • pointerSelectedRef is set to true when selecting a definition via touch/pen, but handleDefinitionSelect closes the picker (unmounting items) so cmdk may never call onSelect to clear the ref. That can cause the next (keyboard/mouse) onSelect to be ignored once. Add a timeout fallback reset after handling the pointer selection.
            if (e.target instanceof Element && e.target.closest("button"))
              return;
            pointerSelectedRef.current = true;
            handleDefinitionSelect(definition);
          }

src/components/Common/ResourceDefinitionCategoryPicker.tsx:597

  • pointerSelectedRef is set to true on touch/pen pointerup, but if handleCategorySelect causes the item to unmount before cmdk fires onSelect, the ref may never get reset. That can make the next (keyboard/mouse) onSelect get ignored once. Consider resetting the ref after the event loop tick in the pointer handler as a fallback.

This issue also appears in the following locations of the same file:

  • line 631
  • line 676
              onPointerUp={(e) => {
                if (e.pointerType !== "mouse") {
                  pointerSelectedRef.current = true;
                  handleCategorySelect(category.slug, category.title);
                }

@navaspavil
navaspavil marked this pull request as ready for review July 28, 2026 09:08

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/components/Common/ResourceDefinitionCategoryPicker.tsx:623

  • Touch/pen-specific selection behavior is now handled via pointer events + a guard ref, but there’s no automated regression test to ensure (a) tapping a category/definition triggers exactly one navigation/selection and (b) tapping the favorite button does not select/close the item. There are existing Playwright helpers/tests covering this picker via mouse clicks; adding a touch-mode spec would prevent future regressions, especially on iOS Safari.
              onSelect={() => {
                if (pointerSelectedRef.current) {
                  pointerSelectedRef.current = false;
                  return;
                }

Copilot AI review requested due to automatic review settings July 28, 2026 13:56

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

src/components/Common/ResourceDefinitionCategoryPicker.tsx:471

  • isIOSDevice only matches iPhone|iPad|iPod in the user agent; on modern iPadOS Safari the UA can appear as Macintosh (desktop mode), so this still enables autofocus on iPads and reintroduces the keyboard/scroll issues this PR is trying to avoid. Consider extending the check to also treat Mac + touch (navigator.maxTouchPoints > 1) as iPadOS when deciding autofocus.
        autoFocus={!isIOSDevice}

src/components/Common/ResourceDefinitionCategoryPicker.tsx:472

  • This change is explicitly iOS/touch-input specific, but Playwright is currently configured to run only Desktop Chromium (Mobile Safari/WebKit projects are commented out), so there’s no automated regression coverage for the iOS behavior being adjusted here. Please add/enable a Playwright project that exercises touch/WebKit (or add a targeted spec using a touch-enabled context) to cover the iOS interaction regression this PR fixes.
        autoFocus={!isIOSDevice}
      />

Copilot AI review requested due to automatic review settings July 28, 2026 14:00

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

src/components/Common/ResourceDefinitionCategoryPicker.tsx:472

  • To ensure iPadOS devices using a desktop-style user agent (often detected as Mac) don’t autofocus and pop the keyboard unexpectedly, consider disabling autofocus when isMacDevice && isTouchDevice as well.
        placeholder={t(`search_${translationBaseKey}`)}
        value={searchQuery}
        onValueChange={setSearchQuery}
        className="h-9 border-0 focus:ring-0 text-base sm:text-sm"
        autoFocus={!isIOSDevice}
      />

src/components/Common/ResourceDefinitionCategoryPicker.tsx:53

  • isIOSDevice relies on a UA match for iPhone/iPad/iPod. On iPadOS, Safari can report a desktop-style UA containing Macintosh (especially with “Request Desktop Website”), which would make isIOSDevice false and re-enable autofocus on iPads. Consider expanding the import so you can treat isMacDevice && isTouchDevice as iPadOS and disable autofocus there too.

This issue also appears on line 467 of the same file.

import { isIOSDevice } from "@/Utils/utils";

Copilot AI review requested due to automatic review settings July 28, 2026 14:04

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/components/Common/ResourceDefinitionCategoryPicker.tsx:895

  • TabsContent previously used the autoFocus prop, but this change replaces it with a className of "autoFocus", which has no effect (there’s no such Tailwind/util class in the repo). As a result, the search tab content will never autofocus on non‑iOS devices, and the intended conditional behavior won’t work.

Prefer keeping the actual autoFocus prop and gating it with !isIOSDevice, similar to the CommandInput change above.

                  <TabsContent
                    value="search"
                    className={cn("h-full mt-0", !isIOSDevice && "autoFocus")}
                  >

@navaspavil
navaspavil force-pushed the fix-category-selection-ios branch from 089033f to 3bd016e Compare July 28, 2026 14:35
Copilot AI review requested due to automatic review settings July 28, 2026 14:35

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

src/components/Common/ResourceDefinitionCategoryPicker.tsx:472

  • isIOSDevice is derived from /iPhone|iPad|iPod/ on navigator.userAgent, which misses iPadOS Safari when it uses the desktop UA (often reports as "Macintosh"). In that case autoFocus will still be enabled and the iOS keyboard/focus bug may persist on iPads. Consider switching to a more robust iPadOS/iOS detection (ideally by updating the util) before relying on it to gate focus behavior.
        placeholder={t(`search_${translationBaseKey}`)}
        value={searchQuery}
        onValueChange={setSearchQuery}
        className="h-9 border-0 focus:ring-0 text-base sm:text-sm"
        autoFocus={!isIOSDevice}
      />

src/components/Common/ResourceDefinitionCategoryPicker.tsx:896

  • renderMainContent() already renders a CommandInput with autoFocus, so keeping autoFocus on TabsContent is redundant and can lead to competing autofocus targets (and focus landing on a non-interactive container). Prefer removing autoFocus from TabsContent and letting the input control focus.
                  <TabsContent
                    value="search"
                    className="h-full mt-0"
                    autoFocus={!isIOSDevice}
                  >

@coderabbitai coderabbitai Bot 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.

Caution

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

⚠️ Outside diff range comments (1)
src/components/Common/ResourceDefinitionCategoryPicker.tsx (1)

471-471: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use an iPadOS-aware device predicate.

isIOSDevice only checks iPhone|iPad|iPod in the user agent, so desktop-class iPadOS presenting as a Mac reaches these autoFocus attributes as well. Use an Apple/iOS/iPadOS-aware predicate for both the command input and the search tabs content.

  • src/components/Common/ResourceDefinitionCategoryPicker.tsx#L471;
  • src/components/Common/ResourceDefinitionCategoryPicker.tsx#L895.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/Common/ResourceDefinitionCategoryPicker.tsx` at line 471,
Replace the isIOSDevice checks controlling autoFocus in
ResourceDefinitionCategoryPicker.tsx at lines 471 and 895 with an
Apple/iOS/iPadOS-aware device predicate, ensuring autoFocus is disabled for
desktop-class iPadOS as well as traditional iOS devices at both the command
input and search tabs content.

Source: MCP tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/components/Common/ResourceDefinitionCategoryPicker.tsx`:
- Line 471: Replace the isIOSDevice checks controlling autoFocus in
ResourceDefinitionCategoryPicker.tsx at lines 471 and 895 with an
Apple/iOS/iPadOS-aware device predicate, ensuring autoFocus is disabled for
desktop-class iPadOS as well as traditional iOS devices at both the command
input and search tabs content.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ea50fd40-d1ea-4dc8-955f-14a6b6398fd6

📥 Commits

Reviewing files that changed from the base of the PR and between 8ef2071 and 3bd016e.

📒 Files selected for processing (1)
  • src/components/Common/ResourceDefinitionCategoryPicker.tsx

Copilot AI review requested due to automatic review settings July 29, 2026 11:26

@greptile-apps greptile-apps Bot 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/Common/ResourceDefinitionCategoryPicker.tsx`:
- Around line 797-800: Update the `repositionInputs` decision in
`ResourceDefinitionCategoryPicker` to also identify iPadOS desktop-mode
sessions, using a `MacIntel` platform combined with touch support alongside the
existing `isIOSDevice` check. Disable repositioning for either detected iOS or
iPadOS desktop-mode environments while preserving the current behavior on other
platforms.
🪄 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 Plus

Run ID: 6d4dba89-32cc-4e1d-b8d1-12591af9b11d

📥 Commits

Reviewing files that changed from the base of the PR and between 3bd016e and 4a47370.

📒 Files selected for processing (1)
  • src/components/Common/ResourceDefinitionCategoryPicker.tsx

Comment thread src/components/Common/ResourceDefinitionCategoryPicker.tsx Outdated
Copilot AI review requested due to automatic review settings July 29, 2026 12:26

@greptile-apps greptile-apps Bot 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/components/Common/ResourceDefinitionCategoryPicker.tsx:797

  • repositionInputs={false} is applied for all mobile devices here, but the PR description indicates the issue is iOS-specific. Disabling Vaul input repositioning globally on mobile could regress Android behavior (keyboard/scroll handling). Consider making this conditional (e.g., repositionInputs={!isIOSDevice}) like TagConfigFormDrawer does.
        <Drawer
          open={open}
          repositionInputs={false}
          onOpenChange={(newOpen) => {

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.

2 participants