Dialog cancel consistency
See original GitHub issueDescribe the bug
The file dialogs (OpenFileDialog
, SaveFileDialog
, and OpenFileDialog
) do not have consistent return values when pressing cancel. On windows, I get OpenFileDialog
returning empty array, SaveFileDialog
returning null, and OpenFolderDialog
returning an empty string. On linux, all of these return null when pressing cancel.
To Reproduce Open different dialogs on different platforms, press cancel on them, and look at the return values.
private async void Test()
{
OpenFileDialog ofd = new OpenFileDialog();
string[] ofdRes = await ofd.ShowAsync(this);
SaveFileDialog sfd = new SaveFileDialog();
string sfdRes = await sfd.ShowAsync(this);
OpenFolderDialog old = new OpenFolderDialog();
string oldRes = await old.ShowAsync(this);
response = $"openfile: {SetName(ofdRes)}, savefile: {SetName(sfdRes)}, openfolder: {SetName(oldRes)}";
}
private string SetName(string text)
{
if (text == null)
return "[null]";
else if (text == "")
return "[empty]";
else
return $"\"{text}\"";
}
private string SetName(string[] textArr)
{
if (textArr == null)
return "[null]";
else if (textArr.Length == 0)
return "[empty array]";
else
return $"\"{string.Join(", ", textArr)}\"";
}
Expected behavior Should be consistent across all platforms. I’m not entirely sure what the cancel values for these dialogs are supposed to be. Maybe all null like on linux?
Screenshots
Windows Linux
Desktop (please complete the following information):
- OS: Windows, Linux (PopOS w/ XFCE)
- Version 0.10.6
Additional context
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:9 (5 by maintainers)
Top Results From Across the Web
UX writing: an effective 'Cancel' dialog confirmation on Web
Aiming to provide more clarity and guidance on how to design effective 'Cancel' confirmation dialogs on Web apps through specific examples.
Read more >OK-Cancel or Cancel-OK? The Trouble With Buttons
One classic is the order of buttons in dialog boxes: OK / Cancel; Cancel / OK. Both are reasonable choices, and people can...
Read more >Cancel dialog text. Is this good?
I have a dialog that comes up when someone cancels creating a new piece of data. They click cancel and the dialog says:...
Read more >Consistent accept/cancel options in menus/dialog boxes
Consistent accept/cancel options in menus/dialog boxes ... What's missing is a cancel option for popup dialog boxes like yes/no response boxes.
Read more >Why 'Ok' Buttons in Dialog Boxes Work Best on the Right
The 'Cancel' button is the secondary action that takes users back to their ... “Consistency” is a popular word used among designers.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
One argument for returning empty over null is that you wouldn’t need to change anything later if you decided to enable nullable reference types, whereas if you return null you have to change the return type to
string?
andstring[]?
and that would be a breaking change.On PR #6160 i used Linux behavior .
@grokys @kekekeks What behavior do you recommend?