Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 9d77a52

Browse files
committed
Add missing initial state in Simple Price Filter
1 parent 72bd2d9 commit 9d77a52

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/BlockTypes/SimplePriceFilter.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,37 @@ public function render( $attributes = [], $content = '', $block = null ) {
3030
$min_price = get_query_var( self::MIN_PRICE_QUERY_VAR, 0 );
3131
$max_price = get_query_var( self::MAX_PRICE_QUERY_VAR, $max_range );
3232

33+
// CSS variables for the range bar style.
34+
// TODO: Use style directive instead when available.
35+
$__low = 100 * $min_price / $max_range;
36+
$__high = 100 * $max_price / $max_range;
37+
$range_style = "--low: $__low%; --high: $__high%";
38+
3339
store(
3440
array(
3541
'state' => array(
3642
'filters' => array(
37-
'minPrice' => $min_price,
38-
'maxPrice' => $max_price,
39-
'maxRange' => $max_range,
43+
'minPrice' => $min_price,
44+
'maxPrice' => $max_price,
45+
'maxRange' => $max_range,
46+
'rangeStyle' => $range_style,
47+
'isMinActive' => true,
48+
'isMaxActive' => false
4049
)
4150
)
4251
)
4352
);
4453

45-
// CSS variables for the range bar style.
46-
$__low = 100 * $min_price / $max_range;
47-
$__high = 100 * $max_price / $max_range;
48-
$range_style = "--low: $__low%; --high: $__high%";
49-
5054
return "
5155
<div $wrapper_attributes>
5256
<h3>Filter by price</h3>
5357
<div
5458
class='range'
55-
style='$range_style'
56-
data-woo-bind:style='derived.filters.rangeStyle'
59+
data-woo-bind:style='state.filters.rangeStyle'
5760
data-woo-on:mousemove='actions.filters.updateActiveHandle'
5861
>
5962
<div class='range-bar'></div>
6063
<input
61-
class='active'
6264
type='range'
6365
value='$min_price'
6466
min='0'
@@ -69,7 +71,6 @@ class='active'
6971
data-woo-on:change='actions.filters.updateProducts'
7072
>
7173
<input
72-
class=''
7374
type='range'
7475
value='$max_price'
7576
min='0'

0 commit comments

Comments
 (0)