Skip to content

Commit 029c429

Browse files
committed
Disable button if field is empty
1 parent bbe0ab7 commit 029c429

4 files changed

Lines changed: 22 additions & 7 deletions

File tree

assets/css/admin.css

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,13 @@ button.prpl-info-icon {
324324
transition: all 0.25s ease-in-out;
325325
}
326326

327-
&:hover,
328-
&:focus {
327+
&:disabled {
328+
opacity: 0.5;
329+
pointer-events: none;
330+
}
331+
332+
&:not([disabled]):hover,
333+
&:not([disabled]):focus {
329334
background: #cf2441;
330335

331336
&::after {
@@ -342,8 +347,8 @@ button.prpl-info-icon {
342347
.prpl-wrap button.prpl-button-secondary {
343348
background: var(--prpl-color-gray-3);
344349

345-
&:hover,
346-
&:focus {
350+
&:not([disabled]):hover,
351+
&:not([disabled]):focus {
347352
background: var(--prpl-color-gray-4);
348353
box-shadow: 3px 3px 10px var(--prpl-color-gray-4);
349354
}
@@ -509,3 +514,4 @@ button.prpl-info-icon {
509514
transform: rotate(360deg);
510515
}
511516
}
517+

assets/css/page-widgets/suggested-tasks.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@
456456
transition: all 0.25s ease-in-out;
457457
}
458458

459-
&:hover,
460-
&:focus {
459+
&:not([disabled]):hover,
460+
&:not([disabled]):focus {
461461
background: var(--prpl-color-400-orange); /* WIP: pick exact color */
462462

463463
&::after {

assets/js/recommendations/core-blogdescription.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,12 @@ prplInteractiveTaskFormListener.siteSettings( {
1212
taskId: 'core-blogdescription',
1313
popoverId: 'prpl-popover-core-blogdescription',
1414
} );
15+
16+
document
17+
.querySelector( 'input#blogdescription' )
18+
.addEventListener( 'input', function ( e ) {
19+
const button = document.querySelector(
20+
'[popover-id="prpl-popover-core-blogdescription"] button[type="submit"]'
21+
);
22+
button.disabled = e.target.value.length === 0;
23+
} );

classes/suggested-tasks/providers/class-blog-description.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class="regular-text"
114114
placeholder="<?php \esc_html_e( 'A catchy phrase to describe your website', 'progress-planner' ); ?>"
115115
>
116116
</label>
117-
<button type="submit" class="prpl-button prpl-button-primary" style="color: #fff;">
117+
<button type="submit" class="prpl-button prpl-button-primary" style="color: #fff;" disabled>
118118
<?php \esc_html_e( 'Save', 'progress-planner' ); ?>
119119
</button>
120120
<?php

0 commit comments

Comments
 (0)