Created
February 12, 2025 00:52
-
-
Save sethwhitaker/4ac6daa3a854975c9c04378d68897965 to your computer and use it in GitHub Desktop.
Input Datalist Issue Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --> | |
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'"> | |
<title>Hello World!</title> | |
</head> | |
<body> | |
<h1>Electron Input Datalist Issue</h1> | |
<p style="margin-bottom: 2rem;"> | |
We are using Node.js <span id="node-version"></span>, | |
Chromium <span id="chrome-version"></span>, | |
and Electron <span id="electron-version"></span>. | |
</p> | |
<div> | |
<input placeholder="Search Datalist" list="search-options" autocomplete="off" type="search"> | |
<datalist id="search-options"> | |
<option value="option1">option 1 - Label</option> | |
<option value="option2">option 2 - Label</option> | |
<option value="option3">option 3 - Label</option> | |
<option value="option4">option 4 - Label</option> | |
<option value="option5">option 5 - Label</option> | |
<option value="option6">option 6 - Label</option> | |
<option value="option7">option 7 - Label</option> | |
<option value="option8">option 8 - Label</option> | |
<option value="option9">option 9 - Label</option> | |
<option value="option10">option 10 - Label</option> | |
<option value="option11">option 11 - Label</option> | |
<option value="option12">option 12 - Label</option> | |
<option value="option13">option 13 - Label</option> | |
<option value="option14">option 14 - Label</option> | |
<option value="option15">option 15 - Label</option> | |
<option value="option16">option 16 - Label</option> | |
<option value="option17">option 17 - Label</option> | |
<option value="option18">option 18 - Label</option> | |
<option value="option19">option 19 - Label</option> | |
<option value="option20">option 20 - Label</option> | |
<option value="option21">option 21 - Label</option> | |
<option value="option22">option 22 - Label</option> | |
<option value="option23">option 23 - Label</option> | |
<option value="option24">option 24 - Label</option> | |
<option value="option25">option 25 - Label</option> | |
<option value="option26">option 26 - Label</option> | |
<option value="option27">option 27 - Label</option> | |
<option value="option28">option 28 - Label</option> | |
<option value="option29">option 29 - Label</option> | |
<option value="option30">option 30 - Label</option> | |
<option value="option31">option 31 - Label</option> | |
<option value="option32">option 32 - Label</option> | |
<option value="option33">option 33 - Label</option> | |
<option value="option34">option 34 - Label</option> | |
<option value="option35">option 35 - Label</option> | |
<option value="option36">option 36 - Label</option> | |
<option value="option37">option 37 - Label</option> | |
<option value="option38">option 38 - Label</option> | |
<option value="option39">option 39 - Label</option> | |
<option value="option40">option 40 - Label</option> | |
<option value="option41">option 41 - Label</option> | |
<option value="option42">option 42 - Label</option> | |
<option value="option43">option 43 - Label</option> | |
<option value="option44">option 44 - Label</option> | |
<option value="option45">option 45 - Label</option> | |
<option value="option46">option 46 - Label</option> | |
<option value="option47">option 47 - Label</option> | |
<option value="option48">option 48 - Label</option> | |
<option value="option49">option 49 - Label</option> | |
<option value="option50">option 50 - Label</option> | |
<option value="option51">option 51 - Label</option> | |
<option value="option52">option 52 - Label</option> | |
<option value="option53">option 53 - Label</option> | |
<option value="option54">option 54 - Label</option> | |
<option value="option55">option 55 - Label</option> | |
<option value="option56">option 56 - Label</option> | |
<option value="option57">option 57 - Label</option> | |
<option value="option58">option 58 - Label</option> | |
<option value="option59">option 59 - Label</option> | |
<option value="option60">option 60 - Label</option> | |
<option value="option61">option 61 - Label</option> | |
<option value="option62">option 62 - Label</option> | |
<option value="option63">option 63 - Label</option> | |
<option value="option64">option 64 - Label</option> | |
<option value="option65">option 65 - Label</option> | |
<option value="option66">option 66 - Label</option> | |
<option value="option67">option 67 - Label</option> | |
<option value="option68">option 68 - Label</option> | |
<option value="option69">option 69 - Label</option> | |
<option value="option70">option 70 - Label</option> | |
<option value="option71">option 71 - Label</option> | |
<option value="option72">option 72 - Label</option> | |
<option value="option73">option 73 - Label</option> | |
<option value="option74">option 74 - Label</option> | |
<option value="option75">option 75 - Label</option> | |
<option value="option76">option 76 - Label</option> | |
<option value="option77">option 77 - Label</option> | |
<option value="option78">option 78 - Label</option> | |
<option value="option79">option 79 - Label</option> | |
<option value="option80">option 80 - Label</option> | |
<option value="option81">option 81 - Label</option> | |
<option value="option82">option 82 - Label</option> | |
<option value="option83">option 83 - Label</option> | |
<option value="option84">option 84 - Label</option> | |
<option value="option85">option 85 - Label</option> | |
<option value="option86">option 86 - Label</option> | |
<option value="option87">option 87 - Label</option> | |
<option value="option88">option 88 - Label</option> | |
<option value="option89">option 89 - Label</option> | |
<option value="option90">option 90 - Label</option> | |
<option value="option91">option 91 - Label</option> | |
<option value="option92">option 92 - Label</option> | |
<option value="option93">option 93 - Label</option> | |
<option value="option94">option 94 - Label</option> | |
<option value="option95">option 95 - Label</option> | |
<option value="option96">option 96 - Label</option> | |
<option value="option97">option 97 - Label</option> | |
<option value="option98">option 98 - Label</option> | |
<option value="option99">option 99 - Label</option> | |
<option value="option100">option 100 - Label</option> | |
</datalist> | |
</div> | |
<!-- You can also require other files to run in this process --> | |
<script src="./renderer.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Modules to control application life and create native browser window | |
const { app, BrowserWindow } = require('electron') | |
const path = require('node:path') | |
function createWindow () { | |
// Create the browser window. | |
const mainWindow = new BrowserWindow({ | |
width: 800, | |
height: 600, | |
webPreferences: { | |
preload: path.join(__dirname, 'preload.js') | |
} | |
}) | |
// and load the index.html of the app. | |
mainWindow.loadFile('index.html') | |
// Open the DevTools. | |
// mainWindow.webContents.openDevTools() | |
} | |
// This method will be called when Electron has finished | |
// initialization and is ready to create browser windows. | |
// Some APIs can only be used after this event occurs. | |
app.whenReady().then(() => { | |
createWindow() | |
app.on('activate', function () { | |
// On macOS it's common to re-create a window in the app when the | |
// dock icon is clicked and there are no other windows open. | |
if (BrowserWindow.getAllWindows().length === 0) createWindow() | |
}) | |
}) | |
// Quit when all windows are closed, except on macOS. There, it's common | |
// for applications and their menu bar to stay active until the user quits | |
// explicitly with Cmd + Q. | |
app.on('window-all-closed', function () { | |
if (process.platform !== 'darwin') app.quit() | |
}) | |
// In this file you can include the rest of your app's specific main process | |
// code. You can also put them in separate files and require them here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "slim-cracker-fold-kzr1p", | |
"productName": "slim-cracker-fold-kzr1p", | |
"description": "My Electron application description", | |
"keywords": [], | |
"main": "./main.js", | |
"version": "1.0.0", | |
"author": "Seth.Whitaker", | |
"scripts": { | |
"start": "electron ." | |
}, | |
"dependencies": {}, | |
"devDependencies": { | |
"electron": "34.1.1" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The preload script runs before `index.html` is loaded | |
* in the renderer. It has access to web APIs as well as | |
* Electron's renderer process modules and some polyfilled | |
* Node.js functions. | |
* | |
* https://www.electronjs.org/docs/latest/tutorial/sandbox | |
*/ | |
window.addEventListener('DOMContentLoaded', () => { | |
const replaceText = (selector, text) => { | |
const element = document.getElementById(selector) | |
if (element) element.innerText = text | |
} | |
for (const type of ['chrome', 'node', 'electron']) { | |
replaceText(`${type}-version`, process.versions[type]) | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This file is loaded via the <script> tag in the index.html file and will | |
* be executed in the renderer process for that window. No Node.js APIs are | |
* available in this process because `nodeIntegration` is turned off and | |
* `contextIsolation` is turned on. Use the contextBridge API in `preload.js` | |
* to expose Node.js functionality from the main process. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment