Skip to content

TT-7132 Fix variable shadowing in nameInUse callback in ProjectsScreen#245

Merged
sarahentzel merged 2 commits intodevelopfrom
feature/TT-7132-no-empty-team-proj-name
Apr 8, 2026
Merged

TT-7132 Fix variable shadowing in nameInUse callback in ProjectsScreen#245
sarahentzel merged 2 commits intodevelopfrom
feature/TT-7132-no-empty-team-proj-name

Conversation

@gtryus
Copy link
Copy Markdown
Contributor

@gtryus gtryus commented Apr 8, 2026

The local t variable inside the nameInUse callback shadowed the outer t = cardStrings localization variable, making the code ambiguous and error-prone.

  • ProjectsScreen.tsx: Renamed trimmed-name local from ttrimmedName in nameInUse
// Before — shadows outer `const t = cardStrings`
const t = newName.trim();
if (t === '') return false;
return projects.some(p => (p?.attributes?.name || '').trim().toLowerCase() === t.toLowerCase());

// After
const trimmedName = newName.trim();
if (trimmedName === '') return false;
return projects.some(p => (p?.attributes?.name || '').trim().toLowerCase() === trimmedName.toLowerCase());

…tion

- Trimmed whitespace from team and project names before validation to prevent duplicates.
- Updated nameInUse function to handle empty strings and ensure consistent comparison.
- Enhanced helper text and disabled state logic based on trimmed name values in TeamDialog and ProjectDialog components.
@gtryus gtryus force-pushed the feature/TT-7132-no-empty-team-proj-name branch from dcc85a3 to b86c231 Compare April 8, 2026 20:35
@gtryus gtryus changed the title TT-7144 name handling in Team and Project dialogs for improved validation TT-7132 name handling in Team and Project dialogs for improved validation Apr 8, 2026
@gtryus gtryus requested review from Copilot and sarahentzel April 8, 2026 20:36
Copy link
Copy Markdown
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

Improves team/project name validation in dialogs by trimming whitespace before duplicate checks and commit, reducing accidental duplicates caused by leading/trailing spaces.

Changes:

  • Normalize (trim) team and project names before validation and when committing changes.
  • Update duplicate-name checks (nameInUse) to be more consistent with trimmed comparisons and empty input handling.
  • Adjust helper text and primary action disabled-state logic to use trimmed values.

Reviewed changes

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

File Description
src/renderer/src/routes/ProjectsScreen.tsx Trims project name before duplicate detection in the add-project flow.
src/renderer/src/components/Team/TeamDialog.tsx Trims team name on commit; updates duplicate check and button/helper logic to use trimmed values.
src/renderer/src/components/Team/ProjectDialog/ProjectDialog.tsx Trims project name on commit; disables primary action based on trimmed name and trimmed duplicate check.
src/renderer/src/components/Team/AddCard.tsx Updates duplicate check to compare trimmed project names.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/renderer/src/routes/ProjectsScreen.tsx
Comment thread src/renderer/src/components/Team/AddCard.tsx
Comment thread src/renderer/src/components/Team/ProjectDialog/ProjectDialog.tsx
Comment thread src/renderer/src/components/Team/TeamDialog.tsx
…oid variable shadowing

Agent-Logs-Url: https://github.com/sillsdev/apm/sessions/d2c2f767-0ee1-4b29-9d7c-694ec74a689f

Co-authored-by: gtryus <2340803+gtryus@users.noreply.github.com>
Copilot AI changed the title TT-7132 name handling in Team and Project dialogs for improved validation TT-7132 Fix variable shadowing in ProjectsScreen nameInUse callback Apr 8, 2026
Copilot AI changed the title TT-7132 Fix variable shadowing in ProjectsScreen nameInUse callback TT-7132 Fix variable shadowing in nameInUse callback in ProjectsScreen Apr 8, 2026
@sarahentzel sarahentzel merged commit fc66be7 into develop Apr 8, 2026
1 check passed
@sarahentzel sarahentzel deleted the feature/TT-7132-no-empty-team-proj-name branch April 8, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants