Fix `jr:itext` to return the default `value` node without `form` attribute
- Dominant language
- TypeScript
- Stars
- 38
- Forks
- 22
- PR merge metrics
- No merged PRs in 30d
Description
### Description
The `jr:itext` function, which retrieves the `value` text of an `itext` node for a given ID, incorrectly returns the first `value` node regardless of its `form` attribute. It should prioritize the default `value` node (the one without a `form` attribute). This bug causes incorrect text output in forms, particularly in edge cases where `jr:itext` is used as a string function.
### Expected Behavior
`jr:itext` should return the text of the default `value` node (without a `form` attribute) from the `itext` structure, e.g., "This is the default text" for the following:
```xml
This is an alternative text
This is the default text
```
The function should respect the specified language (e.g., `fr`) or fall back to a default language if none is set.
### Actual Behavior
`jr:itext` returns the first `value` node’s text (e.g., "This is an alternative text" from `This is an alternative text`), ignoring the default node.
[Find related test cases here.](https://github.com/getodk/web-forms/blob/da4b22020c5bc651f1cda8f4a83a67a8a696badd/packages/xpath/test/xforms/jr-itext.test.ts#L218)
### Related Issues
- https://github.com/getodk/web-forms/pull/399#discussion_r2082551898
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with packages/xpath/test/xforms/jr-itext.test.ts around line 218 and inspect the jr:itext implementation it exercises. Verify the language selection and fallback behavior, then ensure the default value node without a form attribute is returned and the related tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100