Only lazy load categories dropdown if there is a large number of categories

This commit is contained in:
James Cocker 2021-03-05 19:03:29 +00:00 committed by GitHub
parent 4a21824247
commit 39ba0e5bfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -312,6 +312,11 @@ class BlogPost extends Page
); );
} }
$shouldLazyLoadCategories = true;
if($this->Categories()->count() < 15) {
$shouldLazyLoadCategories = false;
}
// Get categories and tags // Get categories and tags
// @todo: Reimplement the sidebar // @todo: Reimplement the sidebar
// $options = BlogAdminSidebar::create( // $options = BlogAdminSidebar::create(
@ -326,7 +331,7 @@ class BlogPost extends Page
$this->Categories() $this->Categories()
) )
->setCanCreate($this->canCreateCategories()) ->setCanCreate($this->canCreateCategories())
->setShouldLazyLoad(true), ->setShouldLazyLoad($shouldLazyLoadCategories),
TagField::create( TagField::create(
'Tags', 'Tags',
_t(__CLASS__ . '.Tags', 'Tags'), _t(__CLASS__ . '.Tags', 'Tags'),