-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When loading json into the editor control the double quotes get replaces with invalid quotes #18220
Comments
Hi @JoacimWall. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Done |
This is pretty insane, but the OS is deciding that you want these nice quotes. https://stackoverflow.com/questions/44932863/ios-11-disable-smart-quotes I tried setting this and it helps with keyboard-entered text, but this is more insane:
The OS can just bypass your attempts! This is the "fix":
Not sure if I accept this yet. |
I can reproduce this in Xcode whith this code: import UIKit
class ViewController: UIViewController {
var extractedExpr: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
extractedExpr = UITextView(frame: CGRect(x: 0, y: 0, width: 800, height: 200))
extractedExpr.smartQuotesType = UITextSmartQuotesType.no
let btn = UIButton(type: UIButton.ButtonType.system)
btn.frame = CGRect(x: 0, y: 210, width: 800, height: 40)
btn.setTitle("Go!", for: UIControl.State.normal)
btn.addTarget(self, action: #selector(buttonAction(_:)), for: .touchUpInside)
self.view.addSubview(extractedExpr);
self.view.addSubview(btn);
}
@objc func buttonAction(_ sender:UIButton!) {
print("Button tapped")
extractedExpr.replace(
extractedExpr.textRange(
from: extractedExpr.beginningOfDocument,
to: extractedExpr.endOfDocument)!,
withText: "")
extractedExpr.replace(
extractedExpr.textRange(
from: extractedExpr.beginningOfDocument,
to: extractedExpr.endOfDocument)!,
withText: "Hello \"Matthew\"!")
}
}
Seems this |
OK, so I have a workaround. I am sure this smart quotes not working until you focus the editor is an OS bug since it happens in Xcode. Or maybe it is by design. But, with that knowledge, I have a workaround. To fix the cases where typing in the editor autoformats the text, you can add this to your MauiProgram.cs: .ConfigureMauiHandlers(_ =>
{
#if MACCATALYST
Microsoft.Maui.Handlers.EditorHandler.Mapper.AppendToMapping("Smart", (h, v) =>
{
h.PlatformView.SmartQuotesType = UIKit.UITextSmartQuotesType.No;
h.PlatformView.SmartDashesType = UIKit.UITextSmartDashesType.No;
h.PlatformView.SmartInsertDeleteType = UIKit.UITextSmartInsertDeleteType.No;
});
#endif
}) And then to fix the case of needing a focus, I did this in the code behind of MainPage.xaml.cs: public MainPage(MainViewModel vm)
{
// ...
Loaded += MainPage_Loaded;
}
private void MainPage_Loaded(object sender, EventArgs e)
{
fileEditor.Focus();
fileEditor.Unfocus();
} Let me know if this helps. |
Hi //Joacim |
Description
Hi
the Editor control in MAUI is replacing the double quotes with invalid quotes the make the file invalid to parse as Json.
The char below
is replaced with this before the word
and this after the word with quotes
that create a invalid json
Steps to Reproduce
Link to public reproduction project repository
https://github.com/JoacimWall/Visual-studio-multilingual-extension/tree/main/src/MultilingualClient
Version with bug
8.0.0-rc.2.9373
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
Unknown/Other
Affected platforms
iOS, macOS
Affected platform versions
No response
Did you find any workaround?
If I skip binding the EditFileText to the editor control and just load the json into the string and then save the string the quotes is not replaced.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: