Page MenuHome

'prop_search' used in operator custom draw function: The 'bpy.ops.ui.button_string_clear' button causes the Redo panel of the Active Operator to close
Closed, ArchivedPublic

Description

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 2080 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 516.94

Blender Version
Broken: version: 3.4.0 Alpha, branch: master, commit date: 2022-10-28 14:24, hash: rBf9113b7eb6ee
Worked: /

Short description of error
In a situation where the prop_search is used within an operator custom draw function:
If the user presses the 'X' cross displayed inside the prop_search, supposed to clear the text content of the prop_search text field, the active operator redo panel will be closed.

I imagine, a possible reason for that issue is that the bpy.ops.ui.button_string_clear is itself registrered to allow Undo, causing the active operator to change and therefor the redo panel of the original operator to be closed.
It would be great if this could be avoided when the prop_search is used within an operator's custom draw function. (After all manually deleting the text from the prop_search does not cause that issue.)

Exact steps for others to reproduce the error

  • From the default startup, run the following script:
import bpy

def update_field(self,context):
    print(f"Value changed to: {self.ui_object_search_field}")

class BUGREPORT_OT_BUTTON_SRTING_CLEAR(bpy.types.Operator):
    bl_idname = "object.bugreport_button_string_clear"
    bl_label = "BugReport button_string_clear"
    bl_options = { 'REGISTER', 'UNDO'}
    
    ui_object_search_field:bpy.props.StringProperty(default="", name='Example', update=update_field)
    
    def execute(self, context):
        print(f"execution with param={self.ui_object_search_field}")
        return {'FINISHED'}
    
    def draw(self,context):
        self.layout.prop_search(self, "ui_object_search_field", bpy.context.scene, "objects", results_are_suggestions=True)
    
def register():
    bpy.utils.register_class(BUGREPORT_OT_BUTTON_SRTING_CLEAR)

def unregister():
    bpy.utils.unregister_class(BUGREPORT_OT_BUTTON_SRTING_CLEAR)
    
register()
  • Make sure to have at least one object in the scene (Will be listed in the prop_search)
  • Select an object
  • Press F3, type "bugreport_", in the list select the operator object.bugreport_button_string_clear
  • If needed, expand the Redo panel that could be collapsed in the bottom right part of the viewport.
  • Click on the prop_search, and in the list of objects that should appear, pick an object from the scene.
  • Now, click the little 'x' in the prop_search, expecting to just have the text cleared
  • Notice that instead of having the text cleared, the entire redo panel you were interacting with is now gone

Event Timeline

Julien Heijmans (julienh) renamed this task from 'prop_search': The 'bpy.ops.ui.button_string_clear' button causes the Redo panel of the Active Operator to close to 'prop_search' used in operator custom draw function: The 'bpy.ops.ui.button_string_clear' button causes the Redo panel of the Active Operator to close.Nov 29 2022, 2:23 PM
Julien Heijmans (julienh) created this task.

While I can understand the inconvenience, this doesn't really seem to be a bug. prop_search was not intended to be used in that way.

Blender's code is open and we appreciate the efforts of others to improve existing code, but for this type of problem we cannot direct and commit a developer's time to work on it.

So thanks for the report, but the issue reported here is a request for modified/improved behavior and not a bug in current behavior. Closing as this bug tracker is only for bugs and errors.

For user requests and feedback, please use other channels: https://wiki.blender.org/wiki/Communication/Contact#User_Feedback_and_Requests

For more information on why this isn't considered a bug, visit: https://wiki.blender.org/wiki/Reference/Not_a_bug