sillsdev / sillsdev/languageforge-lexbox

[PB extension] Consider adding languages context

Open
#2,386 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
9
Forks
8
Avg merge
2d 13h
Merged PRs (30d)
49

Description

Prop-Drilling Audit

How props enter the tree

WebViews receive context from the platform (PAPI) as props:

  • LexiconWebViewProps = ProjectWebViewProps & LexiconOptions → supplies projectId,
    analysisLanguage, vernacularLanguage, word (src/types/lexicon.d.ts:90).
  • LexiconLanguages = { analysisLanguage, vernacularLanguage } is mixed into nearly every
    component's props type (src/types/lexicon.d.ts:75).

The three list-bearing web-views — find-word.web-view.tsx, find-related-words.web-view.tsx, add-word.web-view.tsx — are the roots that then drill these values down.

Finding: analysisLanguage + vernacularLanguage — drilled up to 4 levels

The two language tags are read only at the leaves (entry-display-text helpers, DomainsDisplay, AddNewEntry), but every intermediate component must declare and forward them.

Deepest chain (display side):

find-word.web-view ─┐
find-related.web-view ─ analysisLanguage, vernacularLanguage
                      → EntryList            (forwards both; uses neither directly)
                        → EntryListItem      (uses both; forwards analysisLanguage)
                          → DomainsDisplay   (uses analysisLanguage)
                        → EntryDisplay       (uses both; forwards analysisLanguage)
                          → DomainsDisplay   (uses analysisLanguage)

Add side:

*.web-view → AddNewEntryButton (forwards both, uses neither) → AddNewEntry (uses both)

Call sites doing the forwarding:

EntryList (entry-list.tsx:36-42) and AddNewEntryButton (add-new-entry-button.tsx:15-20) are pure pass-through carriers — they never consume the language props themselves.

Recommendation: Introduce a LexiconLanguagesContext ({ analysisLanguage, vernacularLanguage }) provided once at the top of each web-view, with a useLexiconLanguages() hook consumed at the leaves (DomainsDisplay, EntryListItem, EntryDisplay, AddNewEntry). This removes the two props from EntryList, EntryListItem (forwarding), EntryDisplay (forwarding), and AddNewEntryButton entirely. The values are effectively per-web-view constants, so a context is a near-perfect fit (no re-render churn concern).

Suggested action

Add LexiconLanguagesContext + useLexiconLanguages(); provide it in each web-view; consume at the leaves.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/types/lexicon.d.ts and the three roots: src/web-views/find-word.web-view.tsx, find-related-words.web-view.tsx, and add-word.web-view.tsx. Review the forwarding sites listed in the issue, then trace the leaf consumers in src/components and src/utils/entry-display-text.ts. Done means the languages context and hook are provided by each web view and the listed pass-through components no longer forward these props.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.