Skip to content

Commit c512b41

Browse files
committed
FIX Correctly route from non-react to react section.
1 parent c29945a commit c512b41

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

client/dist/js/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/src/boot/BootRoutes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,16 @@ class BootRoutes {
173173
lastPath = window.location.pathname;
174174
}
175175

176+
// When navigating from a non-react route to a react route, we must
177+
// completely load the page for react's router to kick in.
178+
if (ctx.state?.path && this.matchesReactRoute(ctx.state.path)) {
179+
// Add the current path to the history so we can go back to it
180+
history.pushState({}, '');
181+
// Navigate to the new path
182+
window.location = ctx.state.path;
183+
return;
184+
}
185+
176186
// Verify that this is a true state change. E.g. not a hash change.
177187
// This emulates behaviour of old html history.js
178188
const forceReload = ctx.state && ctx.state.__forceReload;

tests/behat/features/admin-routing.feature

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@ Feature: Single-page routing works as expected
55
So that I can get to the areas I want to get to
66

77
Background:
8-
Given I have a config file "fake-asset-admin.yml"
8+
Given the "Company" "Company A" with "Category"="Other"
99
And the "Employee" "Employee A" with "Email"="test@example.com" and "Biography"="<p>some content here</p>" and "DateOfBirth"="1990-06-09"
10-
And the "group" "EDITOR" has permissions "Access to 'Test ModelAdmin' section" and "TEST_DATAOBJECT_EDIT"
10+
# Page access is required to see the Company object
11+
And the "group" "EDITOR" has permissions "Access to 'Pages' section" and "Access to 'Test ModelAdmin' section" and "CMS_ACCESS_AssetAdmin" and "TEST_DATAOBJECT_EDIT"
1112
And I am logged in as a member of "EDITOR" group
1213

14+
Scenario: Non-react sections correctly route to react sections
15+
When I go to "/admin/test"
16+
Then I wait for 2 seconds
17+
Then I click "Company A" in the "#Form_EditForm" element
18+
And I click "behat link to file" in the "#Form_ItemEditForm" element
19+
Then I should see "Files" in the ".cms-content.AssetAdmin .breadcrumb__container" element
20+
1321
Scenario: Admin sections can start with the same string as a react section
22+
Given I have a config file "fake-asset-admin.yml"
1423
When I go to "/admin/assets-test"
1524
Then I should see "Add Company"

tests/behat/features/gridfield-inline-delete.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Feature: GridField inline delete
1616
And I go to "/admin/test"
1717

1818
Scenario: I can see toast message when I successfully delete a record by clicking the Delete button in action menu
19-
Given I take a screenshot after every step
2019
When I click "Company C" in the "#Form_EditForm" element
2120
And I click "Employees" in the ".ui-tabs-nav" element
2221
Then I should see "Employee A" in the "#Form_ItemEditForm_Employees" element

0 commit comments

Comments
 (0)