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

fix: pickListItem. spacebar on secondaryAction no longer toggles selection #326

Merged
merged 19 commits into from
Oct 22, 2019

Conversation

pr3tori4n
Copy link
Contributor

Related Issue: #309

Summary

pressing spacebar while the secondary action is focused no longer checks/unchecks the list item.

No longer checks/unchecks the list item
@pr3tori4n pr3tori4n added the bug Something isn't working label Oct 1, 2019
@pr3tori4n pr3tori4n requested review from jcfranco and driskull October 1, 2019 19:41
@pr3tori4n pr3tori4n self-assigned this Oct 1, 2019
Copy link
Member

@driskull driskull left a comment

Choose a reason for hiding this comment

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

I think there are a couple issues with the structure here. The onclick for the secondaryAction should be a <button> element so that it supports spacebar/enter key to trigger it.

What might be better to fix this issue is to move the onclick from the Host to the <label> Then there are no longer any nested "buttons".

@pr3tori4n
Copy link
Contributor Author

Moving the onclick to the label would severely reduce the hit area. I don't think that's a valid option.
image
There something wrong with this approach?

Copy link
Member

@driskull driskull left a comment

Choose a reason for hiding this comment

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

Moving the onclick to the label would severely reduce the hit area. I don't think that's a valid option.

That can be addressed by styling. (Moving the padding from the host to the label).

The issue is similar to what we have in the API layerlist widget. The hit area shouldn't be the whole item, just the label and checkbox. Then you won't have nested buttons or have to prevent the internal click from bubbling.

@driskull driskull requested a review from a team as a code owner October 3, 2019 23:53
@pr3tori4n pr3tori4n changed the title fix: spacebar on secondaryAction fix: pickListItem. spacebar on secondaryAction no longer toggles selection Oct 8, 2019
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

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

Good to merge once @driskull's feedback is addressed.

@pr3tori4n
Copy link
Contributor Author

@driskull I made the updates you suggested, however I still had to keep the onkeydown event on the host because I was getting a typescript error when I tried putting it on the label. Therefore I also had to keep that condition in the event handler.

@driskull
Copy link
Member

driskull commented Oct 8, 2019

Ok.

onkeydown event on the host because I was getting a typescript error when I tried putting it on the label.

I ran into that issue before and used a onkeyup instead. I'm not sure if typescript allows for putting an onkeydown on a div.

@jcfranco
Copy link
Member

jcfranco commented Oct 8, 2019

That's weird. I don't see why it would be typed to allow one vs the other. Maybe it's a Stencil bug.

@driskull
Copy link
Member

driskull commented Oct 8, 2019

yeah. I'm not sure either. Maybe some investigation or bug issue for them.

@pr3tori4n would onKeyUp work for the use case?

Copy link
Member

@driskull driskull left a comment

Choose a reason for hiding this comment

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

Can you try moving the onKeyDown to the <label> element. I think an update might have fixed that bug. 👍

Good to merge once conflicts resolved.

@pr3tori4n
Copy link
Contributor Author

pr3tori4n commented Oct 22, 2019

neither onKeydown or onKeyup is passing typescript validation on the label element.

@driskull how would you like to proceed?

@driskull
Copy link
Member

neither onKeydown or onKeyup is passing typescript validation on the label element.

Checked out local branch and this seems to work:

<label class={CSS.label} onClick={this.pickListClickHandler} onKeyUp={this.pickListKeyDownHandler}>

@driskull
Copy link
Member

driskull commented Oct 22, 2019

@pr3tori4n Also seeing this:
image

The JSDoc errors

@driskull
Copy link
Member

We can merge this in and have a followup issue for the key handler. Lets fix the jsdoc though.

@driskull driskull added this to the Donny milestone Oct 22, 2019
@pr3tori4n
Copy link
Contributor Author

It might be being fickle on the casing. I was using onKeydown and onKeyup not onKeyUp. Follow up issue sounds good tho.

Harry Robbins added 2 commits October 22, 2019 13:40
@driskull
Copy link
Member

Created issue for the handler. #433

I think we just need to delete the jsdoc for anything with @property and @type as it is unnecessary.

@driskull driskull requested a review from jcfranco October 22, 2019 21:32
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

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

Looking good.

@jcfranco
Copy link
Member

It might be being fickle on the casing. I was using onKeydown and onKeyup not onKeyUp.

It's not being fickle, it's being correct. Look at dist/types/stencil.core.d.ts for reference.

…check for slot on event now that its on the label.
@driskull driskull requested a review from jcfranco October 22, 2019 21:52
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

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

👍

onKeyDown={this.pickListKeyDownHandler}
role="checkbox"
aria-checked={this.isSelected}
tabindex="0"
Copy link
Member

Choose a reason for hiding this comment

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

[Nitpick] We should be using tabIndex, no? We can do inventory on this in a follow-up issue.

Copy link
Member

Choose a reason for hiding this comment

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

Yep. fixed! only found a couple

@driskull driskull merged commit ed23a28 into master Oct 22, 2019
@driskull driskull deleted the hrobbins/picklist-secondaryActionSpaceBar-309 branch October 22, 2019 22:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants