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

phrasing content within a button #368

Merged
merged 6 commits into from
Mar 12, 2018
Merged

Conversation

alexreardon
Copy link
Collaborator

Fixes #359

@alexreardon
Copy link
Collaborator Author

/cc @seancurtis

@alexreardon alexreardon self-assigned this Mar 5, 2018
@alexreardon
Copy link
Collaborator Author

I have run over these changes with @seancurtis and he is happy with them

// function to keep things simple.
// There is no harm checking if the parent is has an interactive tag name even if it cannot have
// any children. We need to perform this loop anyway to check for the contenteditable attribute
const hasAnInteractiveTag: boolean = Boolean(interactiveTagNames[current.tagName.toLowerCase()]);
Copy link
Member

Choose a reason for hiding this comment

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

Any reason why you're using the Boolean constructer to coerce to boolean over !!? !! is more performant but if this isn't being called a lot then it won't make a difference here. Micro optimisations aren't worth it :) https://jsperf.com/bool-vs-doublenot

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It also returns a value (it would return an Boolean object if we used new Boolean(value)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Rather that using a double negative to cast - we are super explicitly casting to boolean :)

// See 'Permitted content' on https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button
// Rather than having two different functions we can consolidate our checks into this single
// function to keep things simple.
// There is no harm checking if the parent is has an interactive tag name even if it cannot have
Copy link
Member

Choose a reason for hiding this comment

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

Typo here: 'parent is has'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i'll fix

Copy link
Member

@Blasz Blasz left a comment

Choose a reason for hiding this comment

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

Looks good, just a few minor comments/questions

phrasing content
</a>
</p>
<button>hello <strong>world</strong></button>
Copy link
Member

Choose a reason for hiding this comment

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

Should we check the case where there are multiple levels of nesting?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is not a test file - it is simply a storybook. I have added tests for a parent, but not multi levels of parentage. I am not sure if a test would be super valueable - thoughts?


it('should start a drag if the target is not an interactive element', () => {
const nonInteractiveTagNames: TagNameMap = {
a: true,
Copy link
Member

Choose a reason for hiding this comment

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

Just out of interest, is there any reason why anchors are not classed as interactive elements?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Their only interaction is a click. We actually allow draggables and drag handles to be anchors - so they can be both clickable as well as draggable. We manage this interaction separately. We completely support an anchor being an anchor as well as draggable. This feels right too. The other elements are more form elements and do not make sense as a thing if you cannot interact with it directly.

Does that help?

@alexreardon alexreardon merged commit 6b4d4bc into master Mar 12, 2018
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.

2 participants