Skip to content
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

4.3: RichTextLabel.text = "" no longer clears contents and RichTextLabel.clear() no longer has an effect outside of scene tree #89091

Closed
Nallebeorn opened this issue Mar 2, 2024 · 1 comment · Fixed by #89100

Comments

@Nallebeorn
Copy link
Contributor

Tested versions

Reproduced in 4.3-dev4. Not reproducible in 4.2.1-stable.

System information

Windows 11

Issue description

I'm not 100% sure if this is in fact a bug, but it is at the very least an unexpected version incompatibility.

The behaviour of RichTextLabel.clear() and RichTextLabel.text = "" is different between Godot 4.2 and 4.3.

The context is instantiating a scene with a single RichTextLabel containing some placeholder text, and then immediately clearing the text when adding the instantiated node to the scene tree (the placeholder text is useful for testing the RichTextLabel scene in isolation).

In Godot 4.2:

  • When calling clear() or setting text = "" before the node is added to the scene tree (between instantiating a scene and calling add_child), the RichTextLabel will appear empty as expected.

In Godot 4.3-dev4:

  • When calling clear() before the node is added to the scene tree (between instantiating a scene and calling add_child), the RichTextLabel still has the placeholder text from the original scene.
  • When setting text = "", either before or after add_child, the original text remains visible. This means you essentially have to call both clear() and set text = "" to fully reset the contents.

Steps to reproduce

extends Control

const TextLabel := preload("res://rich_text_label.tscn")

# Produces expected behavior in 4.2, but in 4.3

func _ready() -> void:
	var label := TextLabel.instantiate() as RichTextLabel
	label.text = ""
	add_child(label)
	#label.clear() # uncommenting this line will produce the expected behavior in 4.3
	label.text = "" # commenting this line will still produce the expected behavior in 4.2

Minimal reproduction project (MRP)

RichTextLabel-Bug-4.3.zip

@AThousandShips
Copy link
Member

It's due to this code:

// If `text` is empty, it could mean that the tag stack is being used instead. Leave it be.
if (text.is_empty()) {
return;
}

CC @YeldhamDev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants