Bug 210613

Summary: Date and Time form controls not showing correct initial values on immediate second invocation.
Product: WebKit Reporter: Megan Gardner <megan_gardner>
Component: New BugsAssignee: Megan Gardner <megan_gardner>
Status: RESOLVED FIXED    
Severity: Normal CC: thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch for landing none

Description Megan Gardner 2020-04-16 11:09:34 PDT
Date and Time form controls not showing correct initial values on immediate second invocation.
Comment 1 Megan Gardner 2020-04-17 17:00:13 PDT
Created attachment 396817 [details]
Patch
Comment 2 Wenson Hsieh 2020-04-17 17:26:20 PDT
Comment on attachment 396817 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=396817&action=review

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4325
> +- (void)updateValueAsNumberForViewController:(double)value

Nit - the “ForViewController:" suffix makes it sound like the argument should be a `UIViewController *`, but instead it’s a value.

What about naming these -updateFocusedElementValueAsNumber: and -updateFocusedElementValue: instead?

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:8488
> +#elif PLATFORM(IOS)

This excludes Mac Catalyst — is that intentional?

> Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm:153
> +    NSDateComponents *components = [calendar components:(NSCalendarUnitHour) fromDate:[_datePicker date]];

Nit - don’t need () around NSCalendarUnitMinute.

> Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm:161
> +    NSDateComponents *components = [calendar components:(NSCalendarUnitMinute) fromDate:[_datePicker date]];

Nit - ditto regarding the ().

> Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm:280
> +    date = [[self dateFormatterForPicker] dateFromString:timeString];

Nit - I don’t think the date local variable adds much value here, but if you prefer to include it, I’d move this down so that it’s just:

NSDate *date = [[self dateFormatterForPicker] dateFromString:timeString];

> Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm:328
> +    if ([self.control isKindOfClass:WKDateTimePopover.class])

Nit - WKDateTimePopover and WKDateTimePicker are not subclasses of each other, so you don’t need the return statements here.
Comment 3 Megan Gardner 2020-04-20 14:17:35 PDT
Created attachment 397014 [details]
Patch for landing
Comment 4 EWS 2020-04-20 14:45:07 PDT
Committed r260402: <https://trac.webkit.org/changeset/260402>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 397014 [details].
Comment 5 Radar WebKit Bug Importer 2020-04-20 14:46:19 PDT
<rdar://problem/62076826>