File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -438,7 +438,8 @@ input[type=number] {
438438 cursor: inherit;
439439}
440440
441- .blocklyMenuItem:hover {
441+ /* State: hover. */
442+ .blocklyMenuItemHighlight {
442443 background-color: rgba(0,0,0,.1);
443444}
444445
Original file line number Diff line number Diff line change @@ -249,9 +249,11 @@ export class Menu {
249249 setHighlighted ( item : MenuItem | null ) {
250250 const currentHighlighted = this . highlightedItem ;
251251 if ( currentHighlighted ) {
252+ currentHighlighted . setHighlighted ( false ) ;
252253 this . highlightedItem = null ;
253254 }
254255 if ( item ) {
256+ item . setHighlighted ( true ) ;
255257 this . highlightedItem = item ;
256258 // Bring the highlighted item into view. This has no effect if the menu is
257259 // not scrollable.
Original file line number Diff line number Diff line change 1212// Former goog.module ID: Blockly.MenuItem
1313
1414import * as aria from './utils/aria.js' ;
15+ import * as dom from './utils/dom.js' ;
1516import * as idGenerator from './utils/idgenerator.js' ;
1617
1718/**
@@ -67,6 +68,7 @@ export class MenuItem {
6768 'blocklyMenuItem ' +
6869 ( this . enabled ? '' : 'blocklyMenuItemDisabled ' ) +
6970 ( this . checked ? 'blocklyMenuItemSelected ' : '' ) +
71+ ( this . highlight ? 'blocklyMenuItemHighlight ' : '' ) +
7072 ( this . rightToLeft ? 'blocklyMenuItemRtl ' : '' ) ;
7173
7274 const content = document . createElement ( 'div' ) ;
@@ -175,6 +177,25 @@ export class MenuItem {
175177 this . checked = checked ;
176178 }
177179
180+ /**
181+ * Highlights or unhighlights the component.
182+ *
183+ * @param highlight Whether to highlight or unhighlight the component.
184+ * @internal
185+ */
186+ setHighlighted ( highlight : boolean ) {
187+ this . highlight = highlight ;
188+ const el = this . getElement ( ) ;
189+ if ( el && this . isEnabled ( ) ) {
190+ const name = 'blocklyMenuItemHighlight' ;
191+ if ( highlight ) {
192+ dom . addClass ( el , name ) ;
193+ } else {
194+ dom . removeClass ( el , name ) ;
195+ }
196+ }
197+ }
198+
178199 /**
179200 * Returns true if the menu item is enabled, false otherwise.
180201 *
You can’t perform that action at this time.
0 commit comments