sillsdev / sillsdev/languageforge-lexbox
[PB extension] Consider adding languages context
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→ suppliesprojectId,
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:
- find-word.web-view.tsx:107-122
- find-related-words.web-view.tsx:156-198
- entry-list.tsx:108-131
- entry-list-item.tsx:70-73
- entry-display.tsx:72-113
- add-new-entry-button.tsx:27-33
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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