Skip to content

Commit 3f9f720

Browse files
justin808claude
andcommitted
Remove unnecessary react-intl SSR safeguards and fix Turbo test
- Removed SSR safeguards from react-intl usage in JSX components - These safeguards were added during initial beta.4 migration - They're not necessary for the shakapacker v9 upgrade - Simplified code by using destructured formatMessage directly - Fixed failing Turbo/Stimulus inline form test - Added explicit wait time for Turbo frame update to complete - Test now properly waits for async Turbo frame navigation All tests passing (38 examples, 0 failures) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent a863bb9 commit 3f9f720

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

client/app/bundles/comments/components/CommentBox/CommentBox.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ class CommentBox extends BaseComponent {
7474

7575
render() {
7676
const { actions, data, intl } = this.props;
77-
// Safeguard for SSR where intl might not be properly initialized
78-
const formatMessage = intl && intl.formatMessage ? intl.formatMessage : (msg) => msg.defaultMessage || '';
77+
const { formatMessage } = intl;
7978
const cssTransitionGroupClassNames = {
8079
enter: css.elementEnter,
8180
enterActive: css.elementEnterActive,

client/app/bundles/comments/components/CommentBox/CommentForm/CommentForm.jsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,8 @@ class CommentForm extends BaseComponent {
101101
}
102102

103103
formHorizontal() {
104-
// Safeguard for SSR where intl might not be properly initialized
105104
const { intl } = this.props;
106-
const formatMessage = intl && intl.formatMessage ? intl.formatMessage : (msg) => msg.defaultMessage || '';
105+
const { formatMessage } = intl;
107106
return (
108107
<div>
109108
<hr />
@@ -158,9 +157,8 @@ class CommentForm extends BaseComponent {
158157
}
159158

160159
formStacked() {
161-
// Safeguard for SSR where intl might not be properly initialized
162160
const { intl } = this.props;
163-
const formatMessage = intl && intl.formatMessage ? intl.formatMessage : (msg) => msg.defaultMessage || '';
161+
const { formatMessage } = intl;
164162
return (
165163
<div>
166164
<hr />
@@ -215,9 +213,8 @@ class CommentForm extends BaseComponent {
215213

216214
// Head up! We have some CSS modules going on here with the className props below.
217215
formInline() {
218-
// Safeguard for SSR where intl might not be properly initialized
219216
const { intl } = this.props;
220-
const formatMessage = intl && intl.formatMessage ? intl.formatMessage : (msg) => msg.defaultMessage || '';
217+
const { formatMessage } = intl;
221218
return (
222219
<div>
223220
<hr />
@@ -320,9 +317,8 @@ class CommentForm extends BaseComponent {
320317
throw new Error(`Unknown form mode: ${this.state.formMode}.`);
321318
}
322319

323-
// Safeguard for SSR where intl might not be properly initialized
324320
const { intl } = this.props;
325-
const formatMessage = intl && intl.formatMessage ? intl.formatMessage : (msg) => msg.defaultMessage || '';
321+
const { formatMessage } = intl;
326322

327323
// For animation with TransitionGroup
328324
// https://reactcommunity.org/react-transition-group/transition-group

client/app/bundles/comments/components/SimpleCommentScreen/ror_components/SimpleCommentScreen.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ class SimpleCommentScreen extends BaseComponent {
7272

7373
render() {
7474
const { handleSetLocale, locale, intl } = this.props;
75-
// Safeguard for SSR where intl might not be properly initialized
76-
const formatMessage = intl && intl.formatMessage ? intl.formatMessage : (msg) => msg.defaultMessage || '';
75+
const { formatMessage } = intl;
7776
const cssTransitionGroupClassNames = {
7877
enter: css.elementEnter,
7978
enterActive: css.elementEnterActive,

spec/stimulus/turbo_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
it "shows inline form when Inline Form link is clicked" do
2121
click_link("Inline Form")
22-
expect(page).to have_css(".form-inline")
22+
expect(page).to have_css(".form-inline", wait: 5)
2323
end
2424

2525
it "shows stacked form when Stacked Form link is clicked" do

0 commit comments

Comments
 (0)