Skip to content

fix(select-tree): handle empty strict root results#220

Merged
CodeWithDennis merged 1 commit into
4.xfrom
fix/empty-strict-root-results
Jul 16, 2026
Merged

fix(select-tree): handle empty strict root results#220
CodeWithDennis merged 1 commit into
4.xfrom
fix/empty-strict-root-results

Conversation

@CodeWithDennis

@CodeWithDennis CodeWithDennis commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes a production crash in the select tree view when strict null parent root nodes are enabled and the result set does not contain an entry for the configured root parent value.

In that situation, buildTreeFromResults() tried to read $resultCache[$parent]['children'] directly. When the category tree is empty, or when filtering leaves no valid root bucket, $resultCache[$parent] is not initialized. PHP then raises an Undefined array key "" warning, which Laravel converts into a ViewException while rendering resources/views/select-tree.blade.php.

Changes

  • Treat missing strict-root children as an empty array instead of reading the array key unconditionally.
  • Preserve the existing behavior for non-strict mode, where orphaned children can still be promoted to root nodes.

Why

The component should be able to render an empty tree without failing. An empty category, an empty query result, or a filtered tree with no root nodes are valid states for the field and should produce an empty option list.

Verification

  • Ran php -l src/SelectTree.php

The full Pest/PHPUnit suite was not run locally.

@CodeWithDennis
CodeWithDennis force-pushed the fix/empty-strict-root-results branch from 255cff3 to 98a7262 Compare July 16, 2026 07:06
@CodeWithDennis
CodeWithDennis merged commit e40d27b into 4.x Jul 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant