Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cc17f9f
Replace old `CustomSelectControl` select control with the V2 legacy a…
fullofcaffeine Apr 18, 2024
33bb57d
Fix option handling logic for legacy adater and update test to reflec…
fullofcaffeine May 10, 2024
f2c059c
Remove debug code
fullofcaffeine May 11, 2024
0e83151
Debug why selectedItem is not selected on mount
fullofcaffeine May 14, 2024
db8379a
Ensure correct item is selected upon mount based on the value passed …
fullofcaffeine May 15, 2024
751b295
Add new test case to make sure initial passed value is selected upon …
fullofcaffeine May 16, 2024
d18f88d
CSS tweaks
fullofcaffeine May 16, 2024
218cc67
More CSS adjustments to make the component behave closer to classic
fullofcaffeine May 16, 2024
ee619f0
Remove unused prop
fullofcaffeine May 16, 2024
ac751d9
Fix experimentalHint custom styling on legacy adapter
fullofcaffeine May 17, 2024
0db8e28
Fix width of popover not always matching the width of the select
fullofcaffeine May 17, 2024
98a0fc4
Improve export name
fullofcaffeine May 17, 2024
e88b0c4
Fix label margin not applying in certain contexts
fullofcaffeine May 18, 2024
d2cfd1d
Add a wrapper around the select as it the main container needs to hav…
fullofcaffeine May 18, 2024
e47adcf
Fix withHint handling
fullofcaffeine May 18, 2024
e38a4c8
Fix tests
fullofcaffeine May 18, 2024
17f6bbd
Revert accidental change
fullofcaffeine May 18, 2024
cd537af
Make the select item text non-selectable
fullofcaffeine May 21, 2024
fd5c051
Merge branch 'trunk' into replace/old-custom-select-control-with-v2-l…
fullofcaffeine May 28, 2024
25c2a47
Test changes
fullofcaffeine Jun 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Debug why selectedItem is not selected on mount
  • Loading branch information
fullofcaffeine committed May 27, 2024
commit 0e83151161010d2a4da8f80f667594f0dec980fd
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export default function FontAppearanceControl( props ) {
name: __( 'Default' ),
style: { fontStyle: undefined, fontWeight: undefined },
};
debugger;

// Combines both font style and weight options into a single dropdown.
const combineOptions = () => {
Expand Down Expand Up @@ -167,6 +168,7 @@ export default function FontAppearanceControl( props ) {

// Find current selection by comparing font style & weight against options,
// and fall back to the Default option if there is no matching option.
debugger;
const currentSelection =
selectOptions.find(
( option ) =>
Expand Down Expand Up @@ -212,9 +214,10 @@ export default function FontAppearanceControl( props ) {
describedBy={ getDescribedBy() }
options={ selectOptions }
value={ currentSelection }
onChange={ ( { selectedItem } ) =>
onChange( selectedItem.style )
}
onChange={ ( { selectedItem } ) => {
debugger;
onChange( selectedItem.style );
} }
/>
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export default function TypographyPanel( {
const slug = mergedFontFamilies?.find(
( { fontFamily: f } ) => f === newValue
)?.slug;
debugger;
onChange(
setImmutably(
value,
Expand Down Expand Up @@ -220,6 +221,7 @@ export default function TypographyPanel( {
// Appearance
const hasAppearanceControl = useHasAppearanceControl( settings );
const appearanceControlLabel = useAppearanceControlLabel( settings );
debugger;
const hasFontStyles = settings?.typography?.fontStyle;
const hasFontWeights = settings?.typography?.fontWeight;
const fontStyle = decodeValue( inheritedValue?.typography?.fontStyle );
Expand All @@ -228,6 +230,7 @@ export default function TypographyPanel( {
fontStyle: newFontStyle,
fontWeight: newFontWeight,
} ) => {
debugger;
onChange( {
...value,
typography: {
Expand Down Expand Up @@ -398,6 +401,9 @@ export default function TypographyPanel( {
isShownByDefault={ defaultControls.fontAppearance }
panelId={ panelId }
>
{ ( () => {
debugger;
} )() }
<FontAppearanceControl
value={ {
fontStyle,
Expand Down
2 changes: 2 additions & 0 deletions packages/block-editor/src/hooks/typography.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const TYPOGRAPHY_SUPPORT_KEYS = [
];

function styleToAttributes( style ) {
debugger;
const updatedStyle = { ...omit( style, [ 'fontFamily' ] ) };
const fontSizeValue = style?.typography?.fontSize;
const fontFamilyValue = style?.typography?.fontFamily;
Expand Down Expand Up @@ -117,6 +118,7 @@ export function TypographyPanel( { clientId, name, setAttributes, settings } ) {
return { style, fontFamily, fontSize };
}
const { style, fontFamily, fontSize } = useSelect( selector, [ clientId ] );
debugger;
const isEnabled = useHasTypographyPanel( settings );
const value = useMemo(
() => attributesToStyle( { style, fontFamily, fontSize } ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function CustomSelectControl( props: LegacyCustomSelectProps ) {
return;
}

console.debug( nextValue );

// Executes the logic in a microtask after the popup is closed.
// This is simply to ensure the isOpen state matches that in Downshift.
await Promise.resolve();
Expand Down