Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

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
Collaborator

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
Collaborator

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
Collaborator

@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 subscribe to this conversation on GitHub. Already have an account? Sign in.
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