Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions main/blocklyinit.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ import {
} from '../ui/blocklyutil.js';
import { toolbox as toolboxDef } from '../toolbox.js';

const mobileSearchMediaQuery = '(max-width: 768px), (max-width: 899px) and (pointer: coarse)';
const isMobileSearchLayout = () => window.matchMedia(mobileSearchMediaQuery).matches;

// Priority 0 — below the 'blocks' serializer's 20, so blocks exist before locks are re-applied.
if (!Blockly.serialization.registry.getClass?.('flockLock')) {
Blockly.serialization.registry.register('flockLock', {
Expand Down Expand Up @@ -762,7 +765,7 @@ export function initializeWorkspace() {
searchInput.placeholder = translate('toolbox_search_placeholder');

let originalParent = searchInput.parentElement;
const isMobile = () => window.matchMedia('(max-width: 768px)').matches;
const isMobile = isMobileSearchLayout;
const isMobileResults = () => window.matchMedia('(max-width: 480px)').matches;

// Get the toolbox search category (used to override matchBlocks and to
Expand Down Expand Up @@ -1074,8 +1077,7 @@ export function initializeWorkspace() {
cancelBtn.addEventListener('mousedown', (e) => e.preventDefault());
cancelBtn.addEventListener('click', closeOverlay);

// Close search overlay if screen resizes above tablet size (768px)
window.matchMedia('(max-width: 768px)').addEventListener('change', (e) => {
window.matchMedia(mobileSearchMediaQuery).addEventListener('change', (e) => {
if (!e.matches && overlay.isConnected) closeOverlay();
});

Expand Down Expand Up @@ -1117,8 +1119,7 @@ export function initializeWorkspace() {
const originalOpen = workspaceSearch.open.bind(workspaceSearch);
const originalClose = workspaceSearch.close.bind(workspaceSearch);

// Mobile workspace search bar (≤480px): full-width fixed bar with prev/next
const isMobileWS = () => window.matchMedia('(max-width: 768px)').matches;
const isMobileWS = isMobileSearchLayout;

const wsMobileBar = document.createElement('div');
wsMobileBar.className = 'ws-search-mobile-bar';
Expand Down Expand Up @@ -1207,7 +1208,7 @@ export function initializeWorkspace() {
wsMobileClose.addEventListener('mousedown', (e) => e.preventDefault());
wsMobileClose.addEventListener('click', () => workspaceSearch.close());

window.matchMedia('(max-width: 768px)').addEventListener('change', (e) => {
window.matchMedia(mobileSearchMediaQuery).addEventListener('change', (e) => {
if (!e.matches && wsMobileBar.isConnected) workspaceSearch.close();
});

Expand Down
15 changes: 9 additions & 6 deletions style/blockly.css
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,9 @@ body[data-theme='low-vision'] .blocklyField text.blocklyText.blocklyFieldText.bl
margin: 0;
box-sizing: border-box;
}
}

@media (max-width: 768px), (max-width: 899px) and (pointer: coarse) {
/* Expanded search overlay — appended to body so it escapes toolbox overflow/transforms */
.mobile-search-overlay::before {
content: '';
Expand Down Expand Up @@ -894,7 +896,7 @@ body[data-theme='low-vision'] .blocklyField text.blocklyText.blocklyFieldText.bl

.mobile-search-empty {
padding: 24px 16px;
color: var(--color-text);
color: var(--color-text-primary);
opacity: 0.6;
font-size: 15px;
text-align: center;
Expand Down Expand Up @@ -922,7 +924,7 @@ body[data-theme='low-vision'] .blocklyField text.blocklyText.blocklyFieldText.bl

.mobile-search-result-name {
font-size: 16px;
color: var(--color-text);
color: var(--color-text-primary);
flex: 1;
}

Expand Down Expand Up @@ -957,7 +959,8 @@ body[data-theme='low-vision'] .blocklyField text.blocklyText.blocklyFieldText.bl
}
}

@media (min-width: 481px) and (max-width: 768px) {
@media (min-width: 481px) and (max-width: 768px),
(min-width: 481px) and (max-width: 899px) and (pointer: coarse) {
.mobile-search-overlay.expanding {
animation: mobile-search-expand 0.2s ease-out forwards;
}
Expand All @@ -966,7 +969,7 @@ body[data-theme='low-vision'] .blocklyField text.blocklyText.blocklyFieldText.bl
}
}

@media (max-width: 768px) {
@media (max-width: 768px), (max-width: 899px) and (pointer: coarse) {
.ws-search-mobile-bar::before {
content: '';
position: absolute;
Expand Down Expand Up @@ -1001,7 +1004,7 @@ body[data-theme='low-vision'] .blocklyField text.blocklyText.blocklyFieldText.bl
border-radius: 4px;
outline: none;
padding: 0 8px;
color: var(--color-text);
color: var(--color-text-primary);
background: var(--color-bg);
}

Expand All @@ -1012,7 +1015,7 @@ body[data-theme='low-vision'] .blocklyField text.blocklyText.blocklyFieldText.bl

.ws-search-mobile-count {
font-size: 13px;
color: var(--color-text);
color: var(--color-text-primary);
opacity: 0.7;
min-width: 36px;
text-align: center;
Expand Down
Loading