bricks/dist/docs/en/progressbar.md
yumoqing 1291f7fee3 fix: UiCode build_options uses valueField/textField fallback to 'value'/'text'
When valueField/textField are not explicitly set in opts, the auto-select
logic (line 1140) and nullable empty-option creation (lines 1144-1145) used
data[0][undefined] which returned undefined, causing:
- Single-option selects to show blank (auto-select failed)
- nullable empty options to have undefined keys

Now extracts vf/tf local variables with ||'value'/||'text' fallback at the
top of build_options(), used consistently throughout.
2026-05-29 23:03:52 +08:00

1.7 KiB

ProgressBar

Control Function: Displays a progress bar to visually represent the percentage completion of a task.
Type: Standard control (extension based on the container control HBox)
Parent Control: bricks.HBox

Initialization Parameters

Parameter Name Type Description
total_value Number (Optional) The total value of the task, used to calculate the progress percentage. Defaults to 100.
bar_cwidth Number (Optional) The height of the progress bar in units of line height. Defaults to 2.

Note

: In the actual code, this.bar_cwidth || 2 is used, but total_value is not utilized within the constructor. It should likely be used in the set_value method together with current and total. There appears to be an issue with undefined variables (current and total) in the current implementation.

Main Events

  • No explicitly defined events: The source code does not bind or trigger any custom events.
  • The control may inherit basic layout events from HBox, but no additional events are registered.

⚠️ Code Issue Notice:

  • In the set_value method, the variables current and total are used but not defined. They should be replaced with v and this.total_value.
  • There is inconsistency in variable naming within the percentage calculation logic: pzt = (current / total) * 100 is calculated first, then percentage is used later. This should be unified using v / this.total_value.

Recommended Fix:

set_value(v) {
    var percentage = this.total_value ? (v / this.total_value) * 100 : 0;
    percentage = Math.max(0, Math.min(100, percentage));
    this.text_w.set_style('width', percentage + '%');
}