Skip to content

Commit

Permalink
Make use of getValue instead of directly referencing the data object
Browse files Browse the repository at this point in the history
  • Loading branch information
louwie17 committed Oct 31, 2024
1 parent 0f1b2dd commit 770c200
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/fields/src/fields/password/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ import { __ } from '@wordpress/i18n';
*/
import type { BasePost } from '../../types';

function PasswordEdit( { data, onChange }: DataFormControlProps< BasePost > ) {
const [ showPassword, setShowPassword ] = useState( !! data.password );
function PasswordEdit( {
data,
onChange,
field,
}: DataFormControlProps< BasePost > ) {
const [ showPassword, setShowPassword ] = useState(
!! field.getValue( { item: data } )
);

const handleTogglePassword = ( value: boolean ) => {
setShowPassword( value );
Expand Down Expand Up @@ -47,7 +53,7 @@ function PasswordEdit( { data, onChange }: DataFormControlProps< BasePost > ) {
password: value,
} )
}
value={ data.password || '' }
value={ field.getValue( { item: data } ) || '' }
placeholder={ __( 'Use a secure password' ) }
type="text"
__next40pxDefaultSize
Expand Down

0 comments on commit 770c200

Please sign in to comment.