Skip to content

Commit 5dfca76

Browse files
arraypressclaude
andcommitted
A country or a currency is picked by typing
Two hundred and fifty countries in a plain select is a scroll nobody finishes. Both code types use the combobox the kit already draws for an enhanced select, and a caller who wants the plain list says so. The counter test asks for the reveal it assumed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Kwx2STJ4EaVaJofEJJ9Zo
1 parent 189a1b2 commit 5dfca76

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

‎src/Types/AbstractCodeType.php‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,29 @@ private function uppercase( mixed $value ): mixed {
5454

5555
return is_string( $value ) ? strtoupper( trim( $value ) ) : $value;
5656
}
57+
58+
/**
59+
* Searchable, unless told not to be.
60+
*
61+
* Two hundred and fifty countries or a hundred and seventy currencies
62+
* in a plain select is a scroll nobody finishes. The combobox the kit
63+
* already draws for an enhanced select types to filter, which is how a
64+
* list this long is meant to be picked from.
65+
*
66+
* @param Field $field The field.
67+
*
68+
* @return bool
69+
*/
70+
protected function uses_enhanced_ui( Field $field ): bool {
71+
return (bool) $field->get( 'enhanced', true );
72+
}
73+
74+
/**
75+
* The configuration keys this type reads.
76+
*
77+
* @return string[]
78+
*/
79+
public function config_keys(): array {
80+
return array_merge( parent::config_keys(), [ 'enhanced' ] );
81+
}
5782
}

‎tests/CounterTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function test_a_textarea_counts_too(): void {
8484
* a count of the saved secret's length would be a small leak.
8585
*/
8686
public function test_a_password_counts_nothing_it_has_not_shown(): void {
87-
$html = $this->render( 'password', [ 'maxlength' => 64 ], 'hunter2' );
87+
$html = $this->render( 'password', [ 'maxlength' => 64, 'reveal' => true ], 'hunter2' );
8888

8989
$this->assertStringContainsString( '>0 / 64<', $html );
9090

‎tests/PasswordRevealTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function test_the_stored_value_is_still_never_sent_to_the_page(): void {
5353
public function test_an_affix_sits_inside_the_reveal(): void {
5454
$this->assertMatchesRegularExpression(
5555
'/<span class="field-kit__password"><span class="field-kit__adorned[^"]*">.*<\/span><button/s',
56-
$this->render( [ 'prefix' => 'sk_' ] )
56+
$this->render( [ 'reveal' => true, 'prefix' => 'sk_' ] )
5757
);
5858
}
5959

0 commit comments

Comments
 (0)