Skip to content

Commit 3d6e3f9

Browse files
committed
fix: small improvements
1 parent 910a45d commit 3d6e3f9

File tree

5 files changed

+34
-15
lines changed

5 files changed

+34
-15
lines changed

packages/pluggableWidgets/skiplink-web/src/SkipLink.editorConfig.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ export function check(values: any): Problem[] {
2020
message: "Link text is required"
2121
});
2222
}
23-
if (!values.mainContentId) {
24-
errors.push({
25-
property: "mainContentId",
26-
message: "Main content ID is required"
27-
});
28-
}
2923
return errors;
3024
}
3125

packages/pluggableWidgets/skiplink-web/src/SkipLink.editorPreview.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createElement, ReactElement } from "react";
1+
import { ReactElement } from "react";
22
import { SkipLinkPreviewProps } from "../typings/SkipLinkProps";
33

44
export const preview = (props: SkipLinkPreviewProps): ReactElement => {
@@ -25,8 +25,26 @@ export const preview = (props: SkipLinkPreviewProps): ReactElement => {
2525
</a>
2626
</div>
2727
);
28+
} else {
29+
return <a
30+
href={`#${props.mainContentId}`}
31+
style={{
32+
position: "absolute",
33+
top: 0,
34+
left: 0,
35+
background: "#fff",
36+
color: "#0078d4",
37+
padding: "8px 16px",
38+
zIndex: 1000,
39+
textDecoration: "none",
40+
border: "2px solid #0078d4",
41+
borderRadius: 4,
42+
fontWeight: "bold"
43+
}}
44+
>
45+
{props.linkText}
46+
</a>
2847
}
29-
return <div />;
3048
};
3149

3250
export function getPreviewCss(): string {

packages/pluggableWidgets/skiplink-web/src/SkipLink.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ export function SkipLink({ linkText, mainContentId }: SkipLinkProps): null {
2828
// Handler to move focus to the main content
2929
function handleClick(event: MouseEvent) {
3030
event.preventDefault();
31-
const main = document.getElementById(mainContentId);
31+
let main: HTMLElement;
32+
const mainByID = document.getElementById(mainContentId);
33+
if(mainContentId !== "" && mainByID !== null){
34+
main = mainByID;
35+
}
36+
else {
37+
main = document.getElementsByTagName("main")[0];
38+
}
39+
3240
if (main) {
3341
// Store previous tabindex
3442
const prevTabIndex = main.getAttribute("tabindex");

packages/pluggableWidgets/skiplink-web/src/SkipLink.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
<description>A skip link for accessibility, allowing users to jump directly to the main content.</description>
55
<studioProCategory>Accessibility</studioProCategory>
66
<studioCategory>Accessibility</studioCategory>
7-
<helpUrl>https://docs.mendix.com/appstore/widgets/skiplink</helpUrl>
7+
<helpUrl></helpUrl>
88
<properties>
99
<propertyGroup caption="General">
1010
<property key="linkText" type="string" defaultValue="Skip to main content">
1111
<caption>Link text</caption>
12-
<description>The text displayed for the skip link.</description>
12+
<description>The text displayed in the skip link.</description>
1313
</property>
14-
<property key="mainContentId" type="string" defaultValue="main-content">
14+
<property key="mainContentId" type="string">
1515
<caption>Main content ID</caption>
16-
<description>The id of the main content element to jump to.</description>
16+
<description>The id of the main content element to jump to, if left empty the skip link widget will search for a main tag on the page.</description>
1717
</property>
1818
</propertyGroup>
1919
</properties>

packages/pluggableWidgets/skiplink-web/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"skipLibCheck": true,
1919
"noUnusedLocals": true,
2020
"noUnusedParameters": true,
21-
"jsx": "react",
22-
"jsxFactory": "createElement",
21+
"jsx": "react-jsx",
2322
"allowSyntheticDefaultImports": true,
2423
"esModuleInterop": true,
2524
"useUnknownInCatchVariables": false,

0 commit comments

Comments
 (0)