conorhastings / conorhastings/react-native-syntax-highlighter

Cursor disappear when using TextInput

Open
#35 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
184
Forks
26
PR merge metrics
No merged PRs in 30d

Description

When using a TextInput element the cursor disappears when inside color Text.

The cursor only appears when it's at the end of the line.

this is my code:

```jsx
const Editor = ({ initValue, style, onChange = () => {} }: EditorProps) => {
const [value, setValue] = useState(initValue);

const changeHandler = (text: string) => {
setValue(text);
onChange(text);
};
const ast = parse(value);

const headers: HeaderNode[] = ast.filter(isHeaderNode);

console.log(JSON.stringify(ast, null, 4));

return (


{ast.map((node, index) => {
const style = styles[node.type];
if (node.type !== 'link') {
const { content } = node;
const key = `${index}-${content}`;
if (node.type === 'code') {
const { language } = node;
if (!language) {
return (

```{ content }{'\n'}```

);
} else {
return (

```{language}

{ content }

```

);
}
}
return (
{ content }
);
}
})}


);
};
```
![Peek 2023-12-10 18-40](https://github.com/conorhastings/react-native-syntax-highlighter/assets/280241/f84a9aee-8997-4160-8b59-63670eff2aaa)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the provided Editor example, focusing on the TextInput that renders nested Text and SyntaxHighlighter content. Trace how the rendered content affects cursor placement; done means the cursor remains visible when positioned inside the text, not only at the end.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
frontend, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.