Skip to content

Commit

Permalink
See pewresearch/pewresearch-org@f3d28c1 from refs/heads/release/5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
prcdevgitbot committed Mar 12, 2024
1 parent 41d59ad commit 89050b7
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions blocks/attachment-info/attachment-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public function get_attachments($parent_post_id) {
$to_return = array();

foreach ($attachments as $attachment) {
if ( $attachment->menu_order >= 0 ) {
if ( $attachment->menu_order >= 0 ) {
continue;
}
}
if ( false === strpos( $attachment->post_title, ' ' ) ) {
continue;
}
Expand Down
8 changes: 6 additions & 2 deletions blocks/form-input-select/build/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
array(
'label' => 'Option 1',
'value' => 'option-1',
'isSelected' => ( $input_value === 'option-1' ),
'isSelected' => false,
),
);
$input_disabled = array_key_exists( 'disabled', $attributes ) ? $attributes['disabled'] : false;
$input_options = empty($input_options) && array_key_exists( 'prc-block/form-input-options', $block->context) ? $block->context['prc-block/form-input-options'] : $input_options;
$input_options = array_map( function( $option ) use ( $input_value ) {
$option['isSelected'] = $option['value'] === $input_value;
return $option;
}, $input_options );
$input_id = md5( $target_namespace . $input_name );

$input_attrs = \PRC\Platform\Block_Utils\get_block_html_attributes( array(
Expand Down Expand Up @@ -68,7 +72,7 @@
'isError' => false,
'isSuccess' => false,
'isProcessing' => false,
'filteredOptions' => array(),
'filteredOptions' => $input_options,
'options' => $input_options,
)),
'data-wp-init' => 'callbacks.onInit',
Expand Down
2 changes: 1 addition & 1 deletion blocks/form-input-select/build/view.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('@wordpress/interactivity', 'wp-polyfill'), 'version' => '5bfdc1c57c89e970f49e', 'type' => 'module');
<?php return array('dependencies' => array('@wordpress/interactivity', 'wp-polyfill'), 'version' => 'fb23763471d2b4e00624', 'type' => 'module');
2 changes: 1 addition & 1 deletion blocks/form-input-select/build/view.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blocks/form-input-select/build/view.js.map

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions blocks/form-input-select/src/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
array(
'label' => 'Option 1',
'value' => 'option-1',
'isSelected' => ( $input_value === 'option-1' ),
'isSelected' => false,
),
);
$input_disabled = array_key_exists( 'disabled', $attributes ) ? $attributes['disabled'] : false;
$input_options = empty($input_options) && array_key_exists( 'prc-block/form-input-options', $block->context) ? $block->context['prc-block/form-input-options'] : $input_options;
$input_options = array_map( function( $option ) use ( $input_value ) {
$option['isSelected'] = $option['value'] === $input_value;
return $option;
}, $input_options );
$input_id = md5( $target_namespace . $input_name );

$input_attrs = \PRC\Platform\Block_Utils\get_block_html_attributes( array(
Expand Down Expand Up @@ -43,7 +47,7 @@
'data-wp-on--click' => 'actions.onClick',
) );
$option_template = wp_sprintf(
'<li %1$s />',
'<li %1$s/>',
$option_attrs
);
$options_list = wp_sprintf(
Expand All @@ -68,7 +72,7 @@
'isError' => false,
'isSuccess' => false,
'isProcessing' => false,
'filteredOptions' => array(),
'filteredOptions' => $input_options,
'options' => $input_options,
)),
'data-wp-init' => 'callbacks.onInit',
Expand Down
9 changes: 3 additions & 6 deletions blocks/form-input-select/src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ const { actions } = store('prc-block/form-input-select', {
context.label = label;
context.value = value;

console.log('onClick', context, index, label, value);

// find any other isSelected and set to false and then set isSelected
// on the clicked option
// also, reset the filteredOptions to the original options now that we have a value
Expand All @@ -150,12 +152,7 @@ const { actions } = store('prc-block/form-input-select', {
onInit: () => {
const context = getContext();
const { options } = context;
// Loop through everything in options and add a isSelected property equal to false
options.forEach((option) => {
option.isSelected = false;
});
// set filteredOptions immediately...
context.filteredOptions = options;
console.log("form-input-select -> onInit", context, options);
},
onValueChange: () => {
const { ref } = getElement();
Expand Down

0 comments on commit 89050b7

Please sign in to comment.