1- /**
2- * External dependencies
3- */
4- import classnames from 'classnames' ;
5-
61/**
72 * WordPress dependencies
83 */
9- import { BlockControls , InnerBlocks } from '@wordpress/block-editor' ;
4+ import {
5+ BlockControls ,
6+ InnerBlocks ,
7+ useBlockProps ,
8+ } from '@wordpress/block-editor' ;
109import { select , useDispatch } from '@wordpress/data' ;
1110import { useCallback , useMemo , useState } from '@wordpress/element' ;
1211import { compose } from '@wordpress/compose' ;
@@ -43,6 +42,11 @@ import QuestionSettings from './question-settings';
4342import { QuestionTypeToolbar } from './question-type-toolbar' ;
4443import SingleQuestion from './single-question' ;
4544
45+ /**
46+ * External dependencies
47+ */
48+ import classNames from 'classnames' ;
49+
4650let questionOptions = Object . entries ( types ) . map (
4751 ( [ value , settings ] ) => ( {
4852 ...settings ,
@@ -125,7 +129,7 @@ const QuestionEdit = ( props ) => {
125129 props . meta . showValidationErrors && props . meta . validationErrors ?. length ;
126130
127131 const questionGrade = (
128- < div className = "sensei-lms-question-block__grade" >
132+ < div className = "sensei-lms-question-block__grade grade " >
129133 { formatGradeLabel ( options . grade ) }
130134 </ div >
131135 ) ;
@@ -170,6 +174,14 @@ const QuestionEdit = ( props ) => {
170174 [ canHaveFeedback ]
171175 ) ;
172176
177+ const blockProps = useBlockProps ( {
178+ className : classNames ( 'sensei-lms-question-block' , {
179+ 'is-draft' : ! title ,
180+ 'is-invalid' : isInvalid ,
181+ 'show-answer-feedback' : showAnswerFeedback ,
182+ } ) ,
183+ } ) ;
184+
173185 if ( ! editable ) {
174186 return (
175187 < QuestionView
@@ -180,30 +192,26 @@ const QuestionEdit = ( props ) => {
180192 }
181193
182194 return (
183- < div
184- className = { classnames ( 'sensei-lms-question-block' , {
185- 'is-draft' : ! title ,
186- 'is-invalid' : isInvalid ,
187- 'show-answer-feedback' : showAnswerFeedback ,
188- } ) }
189- >
190- { questionIndex }
191- { isSingle && < SingleQuestion { ...props } /> }
192- < h2 className = "sensei-lms-question-block__title" >
193- < SingleLineInput
194- placeholder = { __ ( 'Question Title' , 'sensei-lms' ) }
195- value = { title }
196- onChange = { ( nextValue ) =>
197- setAttributes ( { title : nextValue } )
198- }
199- onEnter = { selectDescription }
200- onRemove = { ( ) => removeBlock ( clientId ) }
201- />
202- </ h2 >
203- { AnswerBlock . subtitle && (
204- < AnswerBlock . subtitle isQuestionSelected = { hasSelected } />
205- ) }
206- { showContent && questionGrade }
195+ < div { ...blockProps } >
196+ < div className = "sensei-lms-question-block__header" >
197+ { questionIndex }
198+ { isSingle && < SingleQuestion { ...props } /> }
199+ < h2 className = "sensei-lms-question-block__title" >
200+ < SingleLineInput
201+ placeholder = { __ ( 'Question Title' , 'sensei-lms' ) }
202+ value = { title }
203+ onChange = { ( nextValue ) =>
204+ setAttributes ( { title : nextValue } )
205+ }
206+ onEnter = { selectDescription }
207+ onRemove = { ( ) => removeBlock ( clientId ) }
208+ />
209+ </ h2 >
210+ { AnswerBlock . subtitle && (
211+ < AnswerBlock . subtitle isQuestionSelected = { hasSelected } />
212+ ) }
213+ { showContent && questionGrade }
214+ </ div >
207215 { hasSelected && shared && < SharedQuestionNotice /> }
208216 { showContent && (
209217 < QuestionContext . Provider value = { questionContext } >
0 commit comments