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

Issue 765 - Sanitize Id #766

Merged
merged 10 commits into from May 5, 2020
Merged

Issue 765 - Sanitize Id #766

merged 10 commits into from May 5, 2020

Conversation

Marc-Andre-Rivet
Copy link
Contributor

@Marc-Andre-Rivet Marc-Andre-Rivet commented Apr 27, 2020

Closes #765

Escapes typical problematic characters that can be used for id and that need to be escaped for CSS selector.

storiesOf('DashTable/CSS override', module)
.add('css with escaped id', () => (<DataTable
setProps={setProps}
id={'`~!@#$%^&*()=+ \\|/.,:;\'"`?[]<>{}'}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without the fix, the table does not render and throws.

Copy link
Contributor

Choose a reason for hiding this comment

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

leading to the developer screaming "~!@#$%^&*()=+ \|/.,:;'"`?[]<>{}"

@Marc-Andre-Rivet Marc-Andre-Rivet marked this pull request as ready for review April 27, 2020 15:27
/>))
.add('stringified object as id', () => (<DataTable
{...props}
id={{ id: 3, group: 'A' }}
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW you're never going to actually get an object sent to the component by the renderer as an id - the renderer stringifies the id first, and does so as sorted JSON, so you'll get '{"group":"A","id":3}'

Does DataTable separately stringify ids? Because if I just call CSS.escape on an object it just gives "\[object\ Object\]"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does DataTable separately stringify ids?

Oups.
41981cb

Copy link
Contributor

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

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

Just a small test question #766 (comment) otherwise this looks great! Nice and easy. 💃

@Marc-Andre-Rivet Marc-Andre-Rivet merged commit 83741e4 into dev May 5, 2020
@Marc-Andre-Rivet Marc-Andre-Rivet deleted the 765-sanitize-id branch May 5, 2020 03:09
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.

[BUG] DashTable and Wildcard / Pattern Matching callbacks not working
2 participants