Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: codeSandbox error fixed in Select, SimpleSelect, Selectable #1669

Conversation

ToMESSKa
Copy link
Contributor

@ToMESSKa ToMESSKa commented Sep 4, 2024

Closes: INSTUI-4201

test plan:

  • test if examples in Select, SimpleSelect, Selectable are opened without error in CodeSandbox

@ToMESSKa ToMESSKa self-assigned this Sep 4, 2024
Copy link

github-actions bot commented Sep 4, 2024

PR Preview Action v1.4.7
Preview removed because the pull request was closed.
2024-09-13 07:23 UTC

@ToMESSKa ToMESSKa force-pushed the INSTUI-4201_select_simple-select_and_selectable_examples_have_an_error_in_code_sandbox branch 2 times, most recently from eb11c8d to 5bd5e82 Compare September 4, 2024 10:53
Comment on lines +76 to +85
const cleanedCode = this.props.code.replace(/\s+/g, '')
const lastRenderIndex = cleanedCode.lastIndexOf('render(<')
const endsWithRenderStatement =
lastRenderIndex !== -1 && cleanedCode.endsWith('>)')

const codeBlock = endsWithRenderStatement
? this.props.code
: `render(${this.props.code})`

Copy link
Contributor Author

@ToMESSKa ToMESSKa Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old code split the code into lines and checked if the last line included 'render(<'. However, sometimes the last line was just a ')' despite the code ending in a render function. This resulted in multiple render functions in CodeSandbox. Now, all newline characters and extra spaces are removed from the code, and it is checked whether the code actually ends with render(<...>)

@ToMESSKa ToMESSKa marked this pull request as ready for review September 4, 2024 11:05
Copy link
Collaborator

@matyasf matyasf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment

const codeBlock = shouldRender
? `render(${this.props.code})`
: this.props.code
const cleanedCode = this.props.code.replace(/\s+/g, '')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regexp are so hard to read, please add here a comment on what this one does

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment added

@ToMESSKa ToMESSKa force-pushed the INSTUI-4201_select_simple-select_and_selectable_examples_have_an_error_in_code_sandbox branch from 5bd5e82 to b232e42 Compare September 10, 2024 09:18
@ToMESSKa ToMESSKa merged commit b84b87c into master Sep 13, 2024
11 checks passed
@ToMESSKa ToMESSKa deleted the INSTUI-4201_select_simple-select_and_selectable_examples_have_an_error_in_code_sandbox branch September 13, 2024 07:23
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.

3 participants