diff --git a/typo3/sysext/core/Classes/Database/Query/Restriction/AbstractRestrictionContainer.php b/typo3/sysext/core/Classes/Database/Query/Restriction/AbstractRestrictionContainer.php
index ee5e58b392de4dddccc0d9abfa87ac63dea8ac51..18b2dee6919759e2bfd7e06cbc88adbdd7838dd2 100644
--- a/typo3/sysext/core/Classes/Database/Query/Restriction/AbstractRestrictionContainer.php
+++ b/typo3/sysext/core/Classes/Database/Query/Restriction/AbstractRestrictionContainer.php
@@ -69,7 +69,20 @@ abstract class AbstractRestrictionContainer implements QueryRestrictionContainer
      */
     public function removeByType(string $restrictionType): QueryRestrictionContainerInterface
     {
-        unset($this->restrictions[$restrictionType], $this->enforcedRestrictions[$restrictionType]);
+        foreach ($this->restrictions as $type => $instance) {
+            if ($instance instanceof $restrictionType) {
+                unset($this->restrictions[$type]);
+                break;
+            }
+        }
+
+        foreach ($this->enforcedRestrictions as $type => $instance) {
+            if ($instance instanceof $restrictionType) {
+                unset($this->enforcedRestrictions[$type]);
+                break;
+            }
+        }
+
         return $this;
     }
 
diff --git a/typo3/sysext/core/Tests/Unit/Database/Query/Restriction/AbstractRestrictionContainerTest.php b/typo3/sysext/core/Tests/Unit/Database/Query/Restriction/AbstractRestrictionContainerTest.php
index e2bf7c4a4c2c8bba70c7da52f893198214711167..e15016e6b043f6f39afc59b6bbbf9dd2bbf3dce4 100644
--- a/typo3/sysext/core/Tests/Unit/Database/Query/Restriction/AbstractRestrictionContainerTest.php
+++ b/typo3/sysext/core/Tests/Unit/Database/Query/Restriction/AbstractRestrictionContainerTest.php
@@ -19,6 +19,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction;
 
 use PHPUnit\Framework\Attributes\Test;
 use TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression;
+use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
 use TYPO3\CMS\Core\Tests\Unit\Database\Mocks\InstantiatableAbstractRestrictionContainer;
 use TYPO3\CMS\Core\Tests\Unit\Database\Mocks\MockEnforceableQueryRestriction;
 use TYPO3\CMS\Core\Tests\Unit\Database\Mocks\MockQueryRestriction;
@@ -56,6 +57,20 @@ final class AbstractRestrictionContainerTest extends AbstractRestrictionTestCase
         self::assertSame('', (string)$expression);
     }
 
+    #[Test]
+    public function crossClassWillBeRemovedWhenRemovedByType(): void
+    {
+        $restriction = new class () extends HiddenRestriction {};
+
+        $subject = new InstantiatableAbstractRestrictionContainer();
+        $subject->add($restriction);
+        $subject->removeByType(HiddenRestriction::class);
+
+        $GLOBALS['TCA']['aTable']['ctrl']['enablecolumns']['disabled'] = 'hidden';
+        $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
+        self::assertSame('', (string)$expression);
+    }
+
     #[Test]
     public function enforceableRestrictionsWillBeRemovedWhenRemovedByTypeAndRemovedAllIsAdditionallyCalled(): void
     {