FileDialog signals and exits on one click

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bborncr

The documentation states that the on_FileDialog_file_selected() signal should fire only after the OK button is pressed or a file is double-clicked:
Event emitted when the user selects a file (double clicks it or presses the OK button).
However, when I click on a file the FileDialog disappears and the clicked file is not selected until I open the FileDialog a second time.
The code successfully loads and saves but I have to open the FileDialog twice for every operation.
Full project on Github

func _on_SaveButton_pressed():
	$HUD/FileDialog.set_mode(FileDialog.MODE_SAVE_FILE)
	$HUD/FileDialog.show()
	
func _on_LoadButton_pressed():
	$HUD/FileDialog.set_mode(FileDialog.MODE_OPEN_FILE)
	$HUD/FileDialog.show()

func _on_FileDialog_file_selected(path):
	if $HUD/FileDialog.get_mode() == FileDialog.MODE_OPEN_FILE:
		print("Loading...")
		print(path)
		_poses = FileAccess.load(path)
	elif $HUD/FileDialog.get_mode() == FileDialog.MODE_SAVE_FILE:
		print("Saving...")
		print(path)
		FileAccess.save(_poses, path)
:bust_in_silhouette: Reply From: bborncr

FileDialog is really buggy. To mitigate the many issues the _draw function can be overridden. This script is attached to a FileDialog node. In this case setting and refreshing the directory does work and by deselecting the items at least one can choose the file without the dialog closing.

extends FileDialog

func _draw():
	set_current_dir("res://saved_poses")
	deselect_items()