Open learnwithsumit opened 3 years ago
Thanks for the bug report. Meanwhile, you can supply the CSS value with the gridTemplateColumns
option:
Split({
gridTemplateColumns: "150px 1fr 5px 1fr",
minSize: 400,
columnGutters: [
{
track: 2,
element: document.querySelector(".column-gutter"),
},
],
});
Oh wow! I did't know that. May be I missed that in documentation. Thanks a ton @nathancahill
So the issue here is that getMatchedCSSRules doesn't honor media queries. I asked ChatGPT to rewrite it to support media queries and it gave this:
function getMatchedCSSRules(el) {
const matchedRules = [];
function getRulesFromStyleSheet(sheet) {
try {
const rules = sheet.cssRules || sheet.rules;
// Iterate through each rule in the sheet
for (let i = 0; i < rules.length; i++) {
const rule = rules[i];
if (rule.type === CSSRule.MEDIA_RULE) {
// Recursively check media rules for matching rules
getRulesFromStyleSheet(rule);
} else if (rule.type === CSSRule.STYLE_RULE && el.matches(rule.selectorText)) {
// Add matching style rule to matchedRules
matchedRules.push(rule);
}
}
} catch (e) {
// Ignore results on security error
}
}
// Iterate through each style sheet in the document
Array.from(el.ownerDocument.styleSheets).forEach(getRulesFromStyleSheet);
return matchedRules;
}
The last piece was to modify getRawTracks to return tracks[tracks.length - 1] instead of tracks[0] as in CSS AFAIK the last definition wins.
I'm not really setup for JS development, so I'm not able to offer a pull request but if you want to take these code snippets this might do the trick.
Ran into a similar problem with container queries.
@nathancahill Without media-queries support this split grid is practiacaly useless in 2024 with projects that handle responsive web design. Currently it's almost impossible to create grid-based SPA or PWA without media queries. This issue was reported 3 years ago. Can you tell us if there is any chance you will fix this or should we try to find some other JS library to handle draggable grid splitters?
It seems that, splitting not working in case of CSS media queries. Please check the below example:
in this case, I am getting this error : split-grid.js:217 Uncaught Error: Unable to determine grid template tracks from styles