element-hq / element-hq/element-ios

Input command should not be auto-corrected

Open
#7,424 0 comments 0 reactions 0 assignees View on GitHub
A-Composer O-Occasional S-Minor T-Defect
Dominant language
Swift
Stars
1.8k
Forks
544
PR merge metrics
PR metrics pending

Description

### Steps to reproduce

I try to send command `/discardsession`

### Outcome

#### What did you expect?

I expect the input to be identified as command `discardsession`.

#### What happened instead?

Because of the auto-correction feature, the command is rewritten as `/discard session`.

The piece of code repsonsible of this auto-correction is in Riot/modules/Room/Views/InputToolbar/RoomInputToolbarView.swift:sendCurrentMessage() :
```
// Triggers auto-correct if needed.
if self.isFirstResponder {
let temp = UITextField(frame: .zero)
temp.isHidden = true
self.addSubview(temp)
temp.becomeFirstResponder()
self.becomeFirstResponder()
temp.removeFromSuperview()
}
```

I propose that command (string beginning with a '/') should not be auto-corrected.

The code should be:
```
// Triggers auto-correct if needed and if it is not a command.
let isCommand = self.textMessage.hasPrefix("/")
if self.isFirstResponder && !isCommand {
let temp = UITextField(frame: .zero)
temp.isHidden = true
self.addSubview(temp)
temp.becomeFirstResponder()
self.becomeFirstResponder()
temp.removeFromSuperview()
}
```

### Your phone model

iPhone 14 Simulator

### Operating system version

iOS 16

### Application version

Element 1.10.3

### Homeserver

_No response_

### Will you send logs?

No

Contributor guide

Open the contributing guide

Research direction

Start in Riot/modules/Room/Views/InputToolbar/RoomInputToolbarView.swift at sendCurrentMessage(), focusing on the auto-correction block described in the issue. Reproduce with /discardsession on the iPhone 14 Simulator running iOS 16, then verify that commands remain unchanged while ordinary message input retains its existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.