Spaces:
Running
Running
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -440,11 +440,12 @@ PLOTLY_CLICK_JS = """
|
|
| 440 |
if (data && data.points && data.points.length > 0) {
|
| 441 |
const idx = data.points[0].customdata;
|
| 442 |
if (idx !== undefined && idx !== null) {
|
| 443 |
-
const inputEl = document.querySelector('#click-index-input textarea');
|
| 444 |
if (inputEl) {
|
| 445 |
-
const
|
| 446 |
-
window.HTMLTextAreaElement.prototype
|
| 447 |
-
|
|
|
|
| 448 |
nativeSetter.call(inputEl, String(idx));
|
| 449 |
inputEl.dispatchEvent(new Event('input', { bubbles: true }));
|
| 450 |
setTimeout(() => {
|
|
@@ -495,7 +496,7 @@ with gr.Blocks(
|
|
| 495 |
|
| 496 |
click_index = gr.Textbox(
|
| 497 |
value="",
|
| 498 |
-
visible=
|
| 499 |
elem_id="click-index-input",
|
| 500 |
)
|
| 501 |
|
|
@@ -606,4 +607,4 @@ with gr.Blocks(
|
|
| 606 |
logger.info("Gradio app built. Ready to launch.")
|
| 607 |
|
| 608 |
if __name__ == "__main__":
|
| 609 |
-
demo.launch()
|
|
|
|
| 440 |
if (data && data.points && data.points.length > 0) {
|
| 441 |
const idx = data.points[0].customdata;
|
| 442 |
if (idx !== undefined && idx !== null) {
|
| 443 |
+
const inputEl = document.querySelector('#click-index-input textarea') || document.querySelector('#click-index-input input');
|
| 444 |
if (inputEl) {
|
| 445 |
+
const proto = inputEl.tagName === 'TEXTAREA'
|
| 446 |
+
? window.HTMLTextAreaElement.prototype
|
| 447 |
+
: window.HTMLInputElement.prototype;
|
| 448 |
+
const nativeSetter = Object.getOwnPropertyDescriptor(proto, 'value').set;
|
| 449 |
nativeSetter.call(inputEl, String(idx));
|
| 450 |
inputEl.dispatchEvent(new Event('input', { bubbles: true }));
|
| 451 |
setTimeout(() => {
|
|
|
|
| 496 |
|
| 497 |
click_index = gr.Textbox(
|
| 498 |
value="",
|
| 499 |
+
visible=True,
|
| 500 |
elem_id="click-index-input",
|
| 501 |
)
|
| 502 |
|
|
|
|
| 607 |
logger.info("Gradio app built. Ready to launch.")
|
| 608 |
|
| 609 |
if __name__ == "__main__":
|
| 610 |
+
demo.launch(css="#click-index-input { position:absolute !important; width:1px !important; height:1px !important; overflow:hidden !important; opacity:0 !important; pointer-events:none !important; }")
|