-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add d2l-input-time Component #18
Conversation
Will look more into the failing galen tests tomorrow |
|
||
_updateFormater: function(locale, overrides) { | ||
this._setFormatter(new d2lIntl.DateTimeFormat(locale, { locale: overrides })); | ||
this._setParser(new d2lIntl.DateTimeParse(locale, { locale: overrides })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in this issue, but we should really switch this over to use the localize behavior's time/date formatting methods at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added #19
--d2l-input-padding: 0.7rem 1rem; | ||
--d2l-input-padding-focus: calc(0.7rem - 1px) calc(1rem - 1px); | ||
|
||
display: inline-flex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this all pre-existing code.
Having display: inline-flex;
on the host
worries me a little. If the consumer happens to put display: inline-block;
on d2l-input-time
, what affect would that have on the internal layout for the component? For specifying internal layout, I think it's better to isolate internals from the public API to avoid risk of stomping on consumer, and vice versa.
host
shadow-DOM
div (where flex or whatever is defined)
things that flex
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, all pre-existing code. I'm not sure the reason for inline-flex
, inline-block
seems to do the same thing other than 10px of padding at the bottom disappears. Feels weird making an issue for this when I could just do it now, but I'm not sure if this breaks a usage in a form somewhere
} | ||
|
||
d2l-dropdown-content { | ||
--d2l-dropdown-verticaloffset: 10px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there is an option for this in the d2l-dropdown-content-behavior. Are we able to use that? I'm also wondering if we will see a pattern emerge for a smaller offset - this seems like something that we'll begin to see inconsistency on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment above the property has it marked as private, so I think the intention is to set this using the css variable as above. The 20px default does seem very large and looks odd, but it probably makes more sense when there's some kind of connector or error like a menu has
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the vertical-offset
option was added to support Navbars, since the dropdown would appear too low given the specific aesthetic of those openers. The default was intended to work with buttons and the openers in the dropdown collection, and for the most part, we wanted to keep things consistent unless the case was "special"... and so the property was commented as "private" to discourage that.
In doing some poking around, there appears to be some inconsistency that's cropped up already. I suspect some of that could be the same - perhaps not 20px, but not all different either. It would be good if we could reel that in... figure out the common thread there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added #25 to address if we don't move to select.
@apply --d2l-body-compact-text; | ||
color: var(--d2l-color-tungsten); | ||
font-style: italic; | ||
padding-top: 10px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like maybe we should follow rule of "6"s. Not sure how much of that is up for grabs though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used to center the timezone text beside the dropdown
, so I think that would require changes to dropdown
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok. It's a minor thing. If one day dropdown is updated for the design spacing changes, this would then need to be updated too. Something seemingly small that has ripple effects. :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I misunderstood where the timezone was supposed to go, so this doesn't actually rely on the height of the dropdown. So we can change the value, but then it will cause a visual difference for anyone that pulls in the component. Are we good with that, or do we need to talk to design?
Since @svanherk's just transplanting these input components into |
</style> | ||
|
||
<d2l-dropdown no-auto-open> | ||
<div class="d2l-dropdown-opener" id="opener"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally I think the actual opener (the element the user will click or focus on) should have d2l-dropdown-opener
class. This class is how the dropdown logic locates the focusable opener. The d2l-dropdown-opener-behavior
has some logic that I think expects this, for instance to apply focus to the opener when the use hits [Escape] inside the dropdown content. There's likely a couple more little things like that. So in this case, I think it should be on the input
, but perhaps there is a reason it's not in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's an issue with the scrollbar when you do this, and there's special functionality to handle scrolling what has been selected into view. I think it's related to this issue: https://github.com/BrightspaceUI/time-picker/issues/9
I've added #21 with this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I saw the scrolling bit earlier too. That's one of the behaviors that made me wonder if this should really be using your select implementation. (?) I'm surprised the opener would affect scrolling though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think the select component could be a really good fit. I've been investigating a bit more but I think I'll just throw them in issues and hopefully we can just replace it later and remove those issues altogether.
}, | ||
|
||
attached: function() { | ||
document.body.addEventListener('focus', this.__onAutoCloseFocus, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know what's different about the focus/close logic here vs what dropdown provides? It would be really great if this component did not need to provide custom logic for this, since it's typically the source of many bugs, especially when considering shadow-DOM vs shady.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this causes the menu not to disappear when someone tabs off the input without selecting anything, or clicks elsewhere on the page. It may be related to the opener not being on the right level?
Added #23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it could be because the focusable opener element is not the one marked as the opener. Not sure. Sounds like these scenarios should be handled by dropdown though.
ready: function() { | ||
this.__onAutoCloseFocus = this.__onAutoCloseFocus.bind(this); | ||
this.__onAutoCloseClick = this.__onAutoCloseClick.bind(this); | ||
this.id = this.id || ('d2l-input-time-' + instances++); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, we have a little helper for getting unique Id. D2L.Id.getUniqueId()
.
Sounds good Dave. I wasn't sure how much clean-up was "on the table". ;) I also wonder if this should really be using the |
Yeah, I also wasn't sure if we wanted to do cleanup. I was thinking we should keep breaking changes (like size and look and feel) to a minimum so its easy for others to update just doing a find/replace, and then we could do a sweep through the elements to fix issues and make another major release update. I haven't looked yet, but I expect we'll see similar issues with date and datetime. I'll respond to the comments above and make issues accordingly. @awikkerink are you able to weigh in on any of the questions Dave has about past decisions? |
Ok merging now, I think I added all needed issues but keep discussing if I missed anything! |
Taken from: https://github.com/BrightspaceUI/time-picker
Previous issues: https://github.com/BrightspaceUI/time-picker/issues