-
Notifications
You must be signed in to change notification settings - Fork 215
Move phone to default fields section instead of being handled inline. #11651
Conversation
dbf6bdc to
3e944c8
Compare
|
The release ZIP for this PR is accessible via: Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
3e944c8 to
6fddfa4
Compare
| showShippingMethods: needsShipping && ! prefersCollection, | ||
| showBillingFields: | ||
| ! needsShipping || ! useShippingAsBilling || prefersCollection, | ||
| ! needsShipping || ! useShippingAsBilling || !! prefersCollection, |
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.
TS fix. prefersCollection can be either a boolean or undefined, this accounts for and assumes undefined is false so that showBillingFields and useBillingAsShipping are always boolean.
| value={ billingAddress.phone } | ||
| onChange={ ( value ) => { | ||
| setBillingPhone( value ); | ||
| dispatchCheckoutEvent( 'set-phone-number', { |
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 was not clear why those events were fired by their own (maybe because editing the field didn't trigger the parent set-shipping-address|set-billing-address hook). This is now deleted. It was experimental.
|
Size Change: -659 B (0%) Total Size: 1.56 MB
ℹ️ View Unchanged
|
| addAction( | ||
| `${ actionPrefix }-checkout-set-phone-number`, | ||
| namespace, | ||
| ( { step, ...rest }: { step: string; storeCart: StoreCart } ): void => { | ||
| trackCheckoutStep( step === 'shipping' ? 2 : 3 )( rest ); | ||
| } | ||
| ); |
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 was meant to track at which step we're right now, other events will continue to do so without needing this.
| label: __( 'Phone', 'woo-gutenberg-products-block' ), | ||
| optionalLabel: __( 'Phone (optional)', 'woo-gutenberg-products-block' ), | ||
| autocomplete: 'tel', | ||
| type: 'tel', |
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.
Newly introduced type field.
| ariaDescribedBy={ describedBy } | ||
| value={ value } | ||
| title="" | ||
| title="" // This prevents the same error being shown on hover. |
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 was only mentioned in the original PR #8143 (comment), it's better near the code now.
nielslange
left a 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.
Thanks for working on this, @senadir.
While testing, I noticed that testing this PR is affected by #11583, as toggling the phone field causes this error:
I also noticed that the phone field appears twice on the Checkout block. This affects both the shipping and billing address. This issue is only visible in the frontend, and cannot be reproduced consistently.
Page editor:
|
Frontend:
|
|
Thank you! I will try to reproduce why you're seeing the phone field twice. |
@senadir After deleting the Checkout block and adding it again, I could no longer see this issue. I wonder if the issue was related to me testing the PR with an existing Checkout block. 🤔 |
|
Other than #11583, are you seeing any other issues? |
Nope. The rest is working fine. |
mikejolley
left a 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.
Noticed 2 issues testing this but they might be unrelated/semi-related.
- Toggling phone off then on in the editor causes block error.
- The phone is showed in the condensed address widget when phone is off.
|
Thank you @mikejolley, I understand that both of those issues should be fixed after merging #11714 |
98cd233 to
a6a7f31
Compare
| ) ) } | ||
| </div> | ||
| { address.phone && showPhoneField ? ( | ||
| { address.phone && ! fieldConfig.phone.hidden ? ( |
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.
We now use the fieldConfig setup instead of passing down props.
| { [ | ||
| address.address_1, | ||
| address.address_2, | ||
| ! fieldConfig.address_2.hidden && address.address_2, |
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 also went along and fixed address_2 so it's not visible if the field is not visible.
|
@mikejolley @nielslange I rebased this PR and would appreciate another review. |
mikejolley
left a 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.
I tested your scenarios and placed orders with phone enabled/disabled. Seems to be working as intended. If CI passes you can ship it.
a6a7f31 to
6c58eeb
Compare


This PR moves the shipping and billing phones to be in the default address sections instead of being handled inline, and removes a class of issues related to that, as well as reduce complexity of codebase.
Something like #10602 since we always handled this on our own in the code.
This also fixes an issue in which phone field was always semantically outside the other fields div, and would sometimes render as a full line despite there being space for it to be half line above.
The one change is that
set-billing-phoneandset-shipping-phoneevents are no longer fired,set-shipping-addresssandset-billing-addresswill fire on phone is changed, this aligns it with the rest of fields in that form.Also right now, using locale filters, someone can reposition a phone number if they want.
This is a soft prerequisite to the custom fields project.
Testing Instructions
Do not include in the Testing Notes
Should be tested by the development team exclusively
WooCommerce Core
Feature plugin
Experimental
N/A
Checklist
Required:
[type]label or a[skip-changelog]label.Conditional:
[skip-changelog]label is not present).Changelog