File tree Expand file tree Collapse file tree 2 files changed +37
-4
lines changed
Expand file tree Collapse file tree 2 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,21 @@ export function useGalleryItemStore() {
194194 return isGalleryLoaded ? ( ) => loadFromUrl ( items , legacyIds ) : null ;
195195 } , [ items , legacyIds ] ) ;
196196
197+ const [ isFirstSearch , setFirstSearch ] = useState ( true ) ;
198+ const setSearchTermWrapper = useCallback (
199+ ( newSearchTerm : string | null ) => {
200+ // the default label filter for Showcases can be confusing when it doesn't
201+ // search everything after page load. Remove the filter on the first search only
202+ // to ensure we search everything
203+ if ( isFirstSearch ) {
204+ setSearchFilter ( null ) ;
205+ setFirstSearch ( false ) ;
206+ }
207+ setSearchTerm ( newSearchTerm ) ;
208+ } ,
209+ [ setSearchTerm , isFirstSearch , setSearchFilter ] ,
210+ ) ;
211+
197212 return {
198213 items,
199214 galleryLoaded,
@@ -203,7 +218,7 @@ export function useGalleryItemStore() {
203218 searchFilter,
204219 searchTerm,
205220 isSearchPending,
206- setSearchTerm,
221+ setSearchTerm : setSearchTermWrapper ,
207222 setSearchFilter,
208223 searchResults : memoizedSearchResults ,
209224
Original file line number Diff line number Diff line change @@ -83,10 +83,28 @@ function SandcastleEditor({
8383 const {
8484 settings : { fontFamily, fontSize, fontLigatures } ,
8585 } = useContext ( SettingsContext ) ;
86+ const documentRef = useRef ( document ) ;
8687 useEffect ( ( ) => {
87- internalEditorRef . current ?. updateOptions ( {
88- fontFamily : availableFonts [ fontFamily ] ?. cssValue ?? "Droid Sans Mono" ,
89- } ) ;
88+ const cssName = availableFonts [ fontFamily ] ?. cssValue ?? "Droid Sans Mono" ;
89+ const fontFace = [ ...documentRef . current . fonts . values ( ) ] . find (
90+ ( font ) => font . family === cssName && font . weight === "400" ,
91+ ) ;
92+ if ( fontFace ?. status !== "loaded" ) {
93+ // Monaco needs to check the size of the font for things like cursor position
94+ // and variable highlighting. If it does this check before the font has loaded
95+ // it will get the wrong size and may be horribly offset especially with ligatures
96+ // https://github.com/microsoft/monaco-editor/issues/392
97+ documentRef . current . fonts . load ( `1rem ${ cssName } ` ) . then ( ( ) => {
98+ internalEditorRef . current ?. updateOptions ( {
99+ fontFamily : cssName ,
100+ } ) ;
101+ monaco . editor . remeasureFonts ( ) ;
102+ } ) ;
103+ } else {
104+ internalEditorRef . current ?. updateOptions ( {
105+ fontFamily : cssName ,
106+ } ) ;
107+ }
90108 } , [ fontFamily ] ) ;
91109 useEffect ( ( ) => {
92110 internalEditorRef . current ?. updateOptions ( {
You can’t perform that action at this time.
0 commit comments